## Midterm Exam 2 Review Spring 2003: Re-mixing the recipe

Back to Sp2003 Midterm Review 2

here's what i came up with: the first is how it should sound, the second part is what the loop is actually doing.

Loop A: "test is a test"; inserts "test" at the beginning of the sound
Loop B: "test test a test"; inserts the word "test" after the first test, but twice aas fast because only takes every other sample
Loop C: "test test tset a test"; inserts "test" backwards after the second word test, but twice as fast as the original speed because only takes every other sample
Loop D: "test test tset test test"; inserts the word test again after the last portion, only twice as fast again
Loop E: "test test tset test tset test"; inserts "tset" after the last test, twice as fast
Loop F: "test test tset test tset tset"; inserts tset in place of the last test, only backwards and at normal speed

The final value of targetIndex is 61775. I found this by doing 15443+7720+7720+7720+7720+15443-1. The -1 is because it started at 1, and the other values are found by just counting up the number of values in the given ranges.

Does this look right?
Katie Graybeal

Yeah, that's what I got.
Student116

so do we look at each loop seperately or loop a, then loop a and b, then loop a, b, and c, etc.?

look at them separately. But if you are running it, you will have to remove the last loop each time to get the different sounds in A,B,C,D,E,&F. I got the same results above.
Elijah Karnley

 Will you be able to do figure all of this out WITHOUT running the program? Remember that you won't be able to run the program on the test. Mark Guzdial

That was my next question.REMOVEDwever, to an extend i will.
Elijah

When I looked at these, I got different answers than Katie, so I tried them in JES. I think she found her answers by combining the loops, ie- loop c is really loops a, b, and c together. I am really confused about this question now -should I do it look at the loops like the above answers or do we do each loop seperately? thanx! - REMOVED Joiner

 Think about each loop separately. That's what I mean by re-mixing the recipes. Mark Guzdial

just an addition: for the rest of question 2 there are 2737 samples left in the sound because it previously ended at 65412 and now it ends at 61775... someone can double-check my math... =)
Student68

I also got that the all of the loops make 61776 but the sample is only 55770 long so why is there some left over? I'm confused.

 What makes you think that the sample is only 55770 long? That's just when the word "Test" ends. That's not when the sound ends. Mark Guzdial

what does the -2 mean?, does it still take every other sample? or is it different

When you're copying a word backwards, just putting a 2 won't speed up the sound and take every other sample. You have to use a -2.
Student116

looking at the very first answer, why is every new "test" inserted after the other new test? (like "loop A, loop B, ..." and not "... loop C, loop B, loop A"????

 Ooh – good question! Here's a tip: Watch when targetIndex changes. It gets set at the beginning and then, from then on...it's only incremented! Mark Guzdial

I understand how this works...but how come in loop C the "a" still remains–shouldn't the "tset" have taken the place of it. In loop B the "test" took the place of "is?" Sam Wilkerson

where does the 7720 come from that you got katie??

I have the same question as Sam as well as what does the -1 for the last one do or mean... how does it make it write over the test? - REMOVEDsan REMOVEDlloman

The 7720 is half of the lenght of Test (15444/2 = 7722) This is because we are only taking every other sample with that ",2". I think - REMOVEDsan REMOVEDlloman

For Sam and REMOVEDsan's question regarding why the "a" in loop C remains. It has to do with the Target Index changing.. In the first loop the final value of the Target Index is now 15444, the length of the normal speed "test", (you find this by subtracting the end of the word "a" 40326 from the end of the word "test" 55770 ie (55770-40326=15443), then in loop b the final value of the Target Index becomes 15444+7720 (the length of the second test is half the length of the first test—only every OTHER sample in the second "test" is taken), then in loop C the final value of the Target Index is 15444 (the first "test")+ 7720 (the second "test" twice as fast)+ 7720 (the third backwards "test" that is twice as fast). These numbers add up to a final Target Index Value of 30883 at the end of loop C. The word "a" still remains because it begins at somewhere close to 30900 (remember to account for silent area following the word "is") and our Target Index begins at 30883 causing the word "a" to not be overwritten.... So sorry this explanation was so long! -Genevieve Wolff

 Genevieve, you rock! Mark Guzdial