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

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

reverse a sound

# Reverse a sound
def reverseSound(sound):
  seconds = getLength(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(getLength(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