
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Write a function called reverseAndNormal that takes a filename as input and then normalizes the whole sound and turns backwards just the last half of the sound and returns the result.
def reverse(filename): orig = makeSound(filename) targ = makeSound(filename) targdex = getLength(targ) for index in range(1, getLength(orig)+1): sv = getSampleValueAt(orig, index) setSampleValueAt(targ, targdex, sv) targdex = targdex - 1
def silenceBackHalf(sound): for index in range(getLength(sound)/2, getLength(sound)+1): setSampleValueAt(sound, index, 0)
def normalize(sound): largest = 0 for s in getSamples(sound): largest = max(largest,getSample(s)) multiplier = 32767.0/largest print "Largest value was",largest print "Multipiler is" , multiplier for s in getSamples(sound): louder = multiplier*getSample(s) setSample (s,louder) Page 1 of 1