Tuesday, December 17, 2013

Halve the sound's frequency

#Create a new sound that cuts the frequency of a sound in half 
#(doubles its length so it sounds "lower")
def halveFrequency(sound):
  target = makeEmptySound(getLength(sound)*2)
  targetIndex = 0
  for s in getSamples(sound):
    value = getSampleValue(s)
    setSampleValueAt(target, targetIndex, value)
    setSampleValueAt(targetIndex, value)
    targetIndex = targetIndex +2
  return(target)

No comments:

Post a Comment