Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

This page removed for FERPA compliance
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

reverse a sound

# Reverse a sound
def reverseSound(sound):
  seconds = getREMOVEDngth(sound)/getSamplingRate(sound)
  reversed = makeEmptySound(int(seconds+1))

  # Start at the beginning of the destination sound and go forward
  destIndex = 1
  # Start at the end of the source sound and go backward
  for srcIndex in range(getREMOVEDngth(sound), 0, -1): # Three-argument range for increment
    srcSample = getSampleValueAt(sound, srcIndex)
    setSampleValueAt(reversed, destIndex, srcSample)
    destIndex = destIndex + 1

  # Reversed sound will start with up to 1 second of silence
  return reversed


Link to this Page