def render(self): # Render hit of "key" for "length" amound of seconds # XXX: Currently only uses a string pluck key = (str(self.note), self.length) if key not in Hit.cache: Hit.cache[key] = source.pluck(self.note, self.length) return Hit.cache[key]
def render(self): if self.sound: return pygame.sndarray.array(self.sound)/32767.0 #undo the as_int16 conversion # Render hit of "key" for "length" amound of seconds # XXX: Currently only uses a string pluck key = (str(self.note), self.length) if key not in Hit.cache: Hit.cache[key] = source.pluck(self.note, self.length) return Hit.cache[key]
def render(self): if self.sound: return pygame.sndarray.array( self.sound) / 32767.0 #undo the as_int16 conversion # Render hit of "key" for "length" amound of seconds # XXX: Currently only uses a string pluck key = (str(self.note), self.length) if key not in Hit.cache: Hit.cache[key] = source.pluck(self.note, self.length) return Hit.cache[key]
def render(self): # Render hit of "key" for "length" amound of seconds # XXX: Currently only uses a string pluck key = (str(self.note), self.length) if key not in Hit.cache: if self.soundType == 'pluck': Hit.cache[key] = source.pluck(self.note, self.length) elif self.soundType == 'square': Hit.cache[key] = source.square(self.note, self.length) elif self.soundType == 'sawtooth': Hit.cache[key] = source.sawtooth(self.note, self.length) else: Hit.cache[key] = source.sine(self.note, self.length) return Hit.cache[key]
def render(self): k = (self.name, self.length, self.volume) if k not in Note.renderCache: Note.renderCache[k] = source.pluck(InnerNote(self.name), self.length) * self.volume return Note.renderCache[k]
import numpy from musical.theory import Note, Scale from musical.audio import source, playback # Define key and scale key = Note('C4') scale = Scale(key, 'major') note = key chunks = [] for i in xrange(len(scale)): third = scale.transpose(note, 2) chunks.append(source.pluck(note, 0.5) + source.pluck(third, 0.5)) note = scale.transpose(note, 1) fifth = scale.transpose(key, 4) chunks.append(source.pluck(key, 1.5) + source.pluck(fifth, 1.5)) print "Rendering audio..." data = numpy.concatenate(chunks) # Reduce volume to 50% data = data * 0.5 print "Playing audio..." playback.play(data) print "Done!"
import numpy from musical.theory import Note, Scale from musical.audio import source, playback # Define key and scale key = Note('D3') scale = Scale(key, 'major') note = key chunks = [] for i in xrange(len(scale)/3): third = scale.transpose(note, 2) chunks.append(source.sine(note, 0.5) + source.pluck(third, 0.5)) note = scale.transpose(note, 1) fifth = scale.transpose(key, 4) chunks.append(source.sine(key, 1.5) + source.pluck(fifth, 1.5)) print "Rendering audio..." data = numpy.concatenate(chunks) # Reduce volume to 50% data = data * 0.5 print "Playing audio..." playback.play(data) print "Done!"