Example #1
0
	def buildWave(self, seq):
		assert seq.instrument[0]=='wave'
		strInstrumentPath = seq.instrument[1]
		
		# strInstrumentPath is the relative path and filename of this.
		
		# First, find the bitrate of this.
		if strInstrumentPath in self.cachedAudioBitrates:
			nBits, nSampleRate = self.cachedAudioBitrates[strInstrumentPath]
		else:
			nBits, nSampleRate = self.determineBitrate(strInstrumentPath)
			self.cachedAudioBitrates[strInstrumentPath] = (nBits, nSampleRate)
		
		# Create an empty wave file and add stuff to it
		seqaudiodata = WaveFile(nBits=nBits, nSampleRate=nSampleRate)
		
		for note in seq.notes:
			if note.pitch == 1: #This represents a rest
				seqaudiodata.add_silence(tunescript_bank.scaleTime(note.duration))
			else:
				if (strInstrumentPath, note.pitch) in self.cachedAudio:
					noteSample = self.cachedAudio[(strInstrumentPath, note.pitch)]
				else:
					noteSample = self.renderNote(strInstrumentPath, note.pitch)
					self.cachedAudio[(strInstrumentPath, note.pitch)] = noteSample
				
				tunescript_bank.add_at_length(seqaudiodata.samples, noteSample.samples, int(tunescript_bank.scaleTime(note.duration) * seqaudiodata.nSampleRate))
		return seqaudiodata
    def buildWave(self, seq):
        assert seq.instrument[0] == 'wave'
        strInstrumentPath = seq.instrument[1]

        # strInstrumentPath is the relative path and filename of this.

        # First, find the bitrate of this.
        if strInstrumentPath in self.cachedAudioBitrates:
            nBits, nSampleRate = self.cachedAudioBitrates[strInstrumentPath]
        else:
            nBits, nSampleRate = self.determineBitrate(strInstrumentPath)
            self.cachedAudioBitrates[strInstrumentPath] = (nBits, nSampleRate)

        # Create an empty wave file and add stuff to it
        seqaudiodata = WaveFile(nBits=nBits, nSampleRate=nSampleRate)

        for note in seq.notes:
            if note.pitch == 1:  #This represents a rest
                seqaudiodata.add_silence(
                    tunescript_bank.scaleTime(note.duration))
            else:
                if (strInstrumentPath, note.pitch) in self.cachedAudio:
                    noteSample = self.cachedAudio[(strInstrumentPath,
                                                   note.pitch)]
                else:
                    noteSample = self.renderNote(strInstrumentPath, note.pitch)
                    self.cachedAudio[(strInstrumentPath,
                                      note.pitch)] = noteSample

                tunescript_bank.add_at_length(
                    seqaudiodata.samples, noteSample.samples,
                    int(
                        tunescript_bank.scaleTime(note.duration) *
                        seqaudiodata.nSampleRate))
        return seqaudiodata
	def buildWave(self, seq):
		seqaudiodata = WaveFile(nBits=8*self.sampleSize, nSampleRate=self.sampleRate)
		assert seq.instrument[0]=='synth'
		strInstrument = seq.instrument[1]
		for note in seq.notes:
			if note.pitch == 1:
				seqaudiodata.add_silence(tunescript_bank.scaleTime(note.duration))
			else:
				if (strInstrument, note.pitch) not in self.cachedAudio: # If there's a note we don't have, we'll have to cache it.
					self.cacheNote(strInstrument, note.pitch)
				noteSample = self.cachedAudio[(strInstrument, note.pitch)]
				
				tunescript_bank.add_at_length( seqaudiodata.samples, noteSample.samples, int(tunescript_bank.scaleTime(note.duration) * seqaudiodata.nSampleRate))
		return seqaudiodata
Example #4
0
    def buildWave(self, seq):
        seqaudiodata = WaveFile(nBits=8 * self.sampleSize,
                                nSampleRate=self.sampleRate)
        assert seq.instrument[0] == 'synth'
        strInstrument = seq.instrument[1]
        for note in seq.notes:
            if note.pitch == 1:
                seqaudiodata.add_silence(
                    tunescript_bank.scaleTime(note.duration))
            else:
                if (
                        strInstrument, note.pitch
                ) not in self.cachedAudio:  # If there's a note we don't have, we'll have to cache it.
                    self.cacheNote(strInstrument, note.pitch)
                noteSample = self.cachedAudio[(strInstrument, note.pitch)]

                tunescript_bank.add_at_length(
                    seqaudiodata.samples, noteSample.samples,
                    int(
                        tunescript_bank.scaleTime(note.duration) *
                        seqaudiodata.nSampleRate))
        return seqaudiodata