Midterm Exam 2 Review Spring 2004: Mirroring, Generalized #2
Comments, answers, and questions go here:
(Link back to Sp2004 Midterm 2 Review)
a) From the book:
def mirrorSound(sound):
mirrorpoint=int(getLength(sound)/2.0)
for sampleOffset in range(1,mirrorpoint-1):
samplelater=getSampleObjectAt(sound,mirrorpoint+sampleOffset)
samplebefore=getSampleObjectAt(sound,mirrorpoint-sampleOffset)
value=getSample(samplebefore)
setSample(samplelater, value)
Catherine Covington
This is obvously not correct,..I am getting errors. but is it anywhere close?
def mirrorsound(source):
Mirrorpoint=int(getSamples(source)/2):
for y in range (1, mirrorpoint):
s=getSampleValueAt(source, x, mirrorpoint-y)
s2=getSamleValueAt(source, x, mirrorpoint+y)
setSampleValueAt(s2, s)
Amelia Cipolla
| Amelia, "Mirrorpint" is not the same as "mirrorpoint". Mark Guzdial |
def mirrorfb(filename):
sound= makeSound(filename)
mirrorpoint= int(getLength(sound)/2)
for index in range(1,mirrorpoint):
valueb= getSampleValueAt(sound,index+mirrorpoint)
valuef= getSampleValueAt(sound,mirrorpoint-index)
setSampleValueAt(sound,index+mirrorpoint,valuef)
play(sound)
- this is more like the mirrorPicture functions.
def mirrorstring (string):
mirrorpoint= int(len(string)/2)
mstring= string[0:mirrorpoint]
reversestring= string[mirrorpoint-1::-1]
print mstring + reversestring
I found this from last semesters review page...could we use this on the exam?
| Yes, if you can explain it. Do you understand how it's working? Mark Guzdial |
Link to this Page