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 Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 2 Review Spring 2004: Re-mixing the recipe

Comments, answers, and questions go here:

(Link back to Sp2004 Midterm 2 Review)


In some of the lines the range is (40327,55770) and in others it is reversed (55770,40327). Is this right or should they all be (40327,55770)? Just wondering.

Also, when you use range(40327,55770,2) it should take every two indexes instead of every one (right?). Well what happens when you use (40327,55770,-2)? I am confused.

They're all corect. Suggestion: Copy-paste this into JES, fix the path to your mediasources, and try it. Mark Guzdial


loop a - copies the word test into the target sound
loop b - copies the word test into the target sound skipping every other sample (it's shorter and higher pitched)
loop c - reverses the word test into the target sound skipping every other sample
loop d - same as loop a
loop e - same as loop c
loop f - reverses the word test into the target sound

the final sound is a series of the word test.. you hear it six times, the first time it's normal, the second is high pitched, the third is high pitched backwards, the fourth is high pitched, the fifth is high pitched backwards, and the sixth is normal backwards..

Sana Yousufi

sorry loop d does the same thing as loop b Sana Yousufi

Loop A puts the word "test" at the beginning of the original file. So it would then say "test is a test".

Loop B does the same thing except it increases the frequency of the word "test". So it would end up "test test(which would sound higher and shorter) is a test"

Loop C confused me at first but let me see if I can explain... The deal is it is doing the same thing as Loop B but it is off by one index value. So now you get "test test(higher and shorter) test(also higher and shorter but different by one index number) a test"

Loop D same as loop B

Loop E same as loop C

Loop F samples every index in the word test. So all in all it should sound something like "test test(higher and shorter) test(higher and shorter but off by one index value) test(higher and shorter) test(higher and shorter but off by one index value) test."

Sorry this isn't explained well but it is hard to write what something sounds like. Hope this helps.

Sana, you explained it much better thanks!

For question 2, is the target index 1 when the function finishes?

On question 2, how are we suppose to know then when we cant do it and play it back in jes. we dont know how long the total sound is.
Amelia Cipolla

(a)loop A- puts the word"test" at the beginning of the sound, so that it plays "test is a test", nothing

changes about the word test, it is copied directly
loop B- does the same as A except that it only copies every other sample in the word test and inserts it

after the first "test" created in loop A, so it says "test test a test", so the second "test" is much higher

and faster.
loop C- does the same as loop B except that it copies it processes backwards to create a very similar sould

to loop B but with the alternate sound samples that were skipped in loop b
loop D-same as B
loop E-same as C
loop F- processed backwards so the only difference in it and loop A is that it includes the 55770 and not 40327 and loop a does the opposite

final sound is"(regular)test test test test test (regular)test"
at the end the target index is 61738 I think...(15442x4)
there is nothing left in the sound when look F finished I dont think


how do you find out how long the origional sound was?
how'd I do?
Margaret McIntosh


I'm confused... how do we know that after each loop the sound continues... as in, after loop A, loop B starts, then loop C, etc... From what I understood, it just kept on copying over what it already had... as in, loop F was the only thing that mattered because it was the last loop. Confused – please explain!

Notice that we're only setting the targetIndex ONCE, at the beginning. Thereafter, we're only incrementing it. That allows for simply appending each sound to the end. Mark Guzdial


We have six loops in our sound. Two of them do not skip samples so we find their lengths by subtracting the two range numbers. Any ideas as to how to calculate the length of the loops where we do skip samples? (Hint: Remember that we are skipping every other sample.)Steph Weitzel

Find the difference between the two numbers, then divide that number by two?
Ex. if the range is (a,b) then the length of the loop is absolute int((a-b)/2).
So, for this specific example, it would be absolute interger of (40327-55770)/2.
Is this right?

so for the six loops: 2 of them were of length 15443, 4 of them of length 7721, is the targetIndex at the end 61770?

I am really confused on question 2. I have looked at the posts here and from Fall 2003..and it's still not making any sense..how do you do this problem? :(

Here's the easy way to do question 2: Run the program, and print the length of the sound and the targetIndex. That'll tell you if the targetIndex got all the way to the end. Mark Guzdial


How will we be able to do question 2 if we cant run the program and print the length, etc in the middle of class?
Thanks!
Thomas Sobeck

You can calculate it, just like what everyone's been describing above. But if you are trying to understand it right now, you can print it to see what the values are. You can also print targetIndex between each loop to see just how far each loop goes into the target. Mark Guzdial




Link to this Page