Friday, December 20, 2013

Mix Three Sounds

# This function blends 3 sounds.
def makeMix(sound1, sound2, sound3, mixValue1, mixValue2, mixValue3):
  newLength = min(getLength(sound1) ,getLength(sound2), getLength(sound3))
  newSound = makeEmptySound(newLength)
  for index in range(0,newLength):
    sample1 = getSampleValueAt (sound1, index)
    sample2 = getSampleValueAt (sound2, index)
    sample3 = getSampleValueAt (sound3, index)
    newSample = mixValue1*sample1 + mixValue2*sample2 + mixValue*sample3
    setSampleValueAt (newSound, index, newSample)
  return newSound

No comments:

Post a Comment