In this mini-lab you will gain practice with using the techniques of echoing and shifting sounds.
def echoes(sound, delay, num): soundLength = getNumSamples(sound) newLength = soundLength + (delay*num) # number of samples newSound = makeEmptySound(newLength, int(getSamplingRate(sound))) echoAmp = 1.0 for echoCount in range(num+1): # 60% smaller each time after the original sound for soundIndex in range(soundLength): newSoundIndex = soundIndex + (delay*echoCount) value1 = getSampleValueAt(sound, soundIndex) * echoAmp value2 = getSampleValueAt(newSound, newSoundIndex) setSampleValueAt(newSound, newSoundIndex, value1+value2) echoAmp = echoAmp * .6 return newSound
.wav
file to be
submitted on Kit.
# This function shifts the frequency of a sound by the specified factor # A factor > 1 shortens the frequency, a factor < 1 lengthens frequency def shift(sound, factor): # make the new sound newSound = makeEmptySound(getNumSamples(sound), int(getSamplingRate(sound))) # copy the sample values from original sound into new sound index = 0 for newIndex in range(getNumSamples(newSound)): value = getSampleValueAt(sound, int(index)) setSampleValueAt(newSound, newIndex, value) index = index + factor if (index >= getNumSamples(sound)): index = 0 return newSound
doubleFrequency
and
halfFrequency
functions?