def renderNote(self, strInstrumentPath, n): # Render a note at a certain pitch print 'Rendering',n, '...' # Get the original pitch and data for fundamental note of the sound. if strInstrumentPath in self.cachedAudioOriginals: audioFundamental, audiodata = self.cachedAudioOriginals[strInstrumentPath] else: audioFundamental, audiodata = self.determineAudioFundamental(strInstrumentPath) self.cachedAudioOriginals[strInstrumentPath] = audioFundamental, audiodata self.cachedAudio[(strInstrumentPath, audioFundamental)] = audiodata # We were lucky - the user asked for the fundamental, so we don't need to do anything if n==audioFundamental: return audiodata # Scale the 'fundamental: currentFreq = tunescript_bank.midiToFrequency(nBase) desiredFreq = tunescript_bank.midiToFrequency(n) import copy import audio_effects newaudio = audioFundamental.empty_copy() newaudio.samples = (audioFundamental.samples).__deepcopy__() audio_effects.fx_change_pitch(newaudio, desiredFreq/currentFreq) return newaudio
def renderNote(self, strInstrumentPath, n): # Render a note at a certain pitch print('Rendering', n, '...') # Get the original pitch and data for fundamental note of the sound. if strInstrumentPath in self.cachedAudioOriginals: audioFundamental, audiodata = self.cachedAudioOriginals[ strInstrumentPath] else: audioFundamental, audiodata = self.determineAudioFundamental( strInstrumentPath) self.cachedAudioOriginals[ strInstrumentPath] = audioFundamental, audiodata self.cachedAudio[(strInstrumentPath, audioFundamental)] = audiodata # We were lucky - the user asked for the fundamental, so we don't need to do anything if n == audioFundamental: return audiodata # Scale the 'fundamental: currentFreq = tunescript_bank.midiToFrequency(nBase) desiredFreq = tunescript_bank.midiToFrequency(n) import copy import audio_effects newaudio = audioFundamental.empty_copy() newaudio.samples = (audioFundamental.samples).__deepcopy__() audio_effects.fx_change_pitch(newaudio, float(desiredFreq) / currentFreq) return newaudio
def cacheNote(self, strInstrument, n): if (strInstrument, n) in self.cachedAudio: return print 'Caching',n, '...' audiodata = WaveFile(nBits=8*self.sampleSize, nSampleRate=self.sampleRate) freq = tunescript_bank.midiToFrequency(n) synthesize(audiodata, strInstrument, freq, 2., 0.5) #2 seconds should be sufficient self.cachedAudio[(strInstrument, n)] = audiodata
def cacheNote(self, strInstrument, n): if (strInstrument, n) in self.cachedAudio: return print 'Caching', n, '...' audiodata = WaveFile(nBits=8 * self.sampleSize, nSampleRate=self.sampleRate) freq = tunescript_bank.midiToFrequency(n) synthesize(audiodata, strInstrument, freq, 2., 0.5) #2 seconds should be sufficient self.cachedAudio[(strInstrument, n)] = audiodata