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: Rewrite the Splice

Comments, answers, and questions go here:

(Link back to Sp2004 Midterm 2 Review)


For part b, where it has "targetIndex = targetIndex + 1" in the original code, shouldn't it just be "targetIndex = targetIndex + 2", and for part c it should be "targetIndex = targetIndex + 0.5"?


i'm not sure about part a. could you reword it please?


In this loop:
  targetIndex=1         # targetIndex starts at the beginning
  for sourceIndex in range( 40327, 55770):  # Where the word "Test" is in the sound
    setSampleValueAt(target, targetIndex,  getSampleValueAt( source, sourceIndex))
    targetIndex = targetIndex + 1

It's sourceIndex that's in the for loop, and targetIndex that's incremented. Swap those, but still DO the exact same thing. The first line would be sourceIndex=40327. The for loop would be on targetIndex, and the range would start with 1, since that's what the above loop starts with. Now, fill in the rest. Mark Guzdial


I still do not understand what the question (a) is asking exactly. We went over this in the review session, and I understand the answer... So, are the codes doing the same thing, just doing it in a different manner?

If you understand the WHOLE CODE for parts b and c (and if you know that it is correct), PLEASE PLEASE PLEASE post it!

 def spliceTest():
   file = getMediaPath("thisisatest.wav")
   source = makeSound(file)
   target = makeSound(file)
   targetIndex = 1
   for sourceIndex in range(40327,55770):
     sourceSampleValue = getSampleValueAt(source,sourceIndex)
     setSampleValueAt(target,targetIndex,sourceSampleValue)
     targetIndex = targetIndex + 2
   play(target)
   return target

 def spliceTest():
    file = getMediaPath("thisisatest.wav")
    source = makeSound(file)
    target = makeSound(file)
    targetIndex = 1
    for sourceIndex in range(40327,55770):
      sourceSampleValue = getSampleValueAt(source,sourceIndex)
      setSampleValueAt(target,int(targetIndex),sourceSampleValue)
      targetIndex = targetIndex + 0.5
    play(target)
    return target




a)def spliceTest():
file = r"C:\Documents and Settings\Mark Guzdial\My Documents\mediasources\thisisatest.wav"
source = makeSound(file)
target = makeSound(file)
aourceIndex=40327
for targetIndex in range(1, 55770-40327):
setSampleValueAt(target, targetIndex, getSampleValueAt( source, sourceIndex))
sourceIndex = Index + 1
play(target)
return target

Amy Howard


I DONT UNDERSTAND A!!!

Amy's A and the original program on the Review do the exact same thing. Compare them and see how they handle sourceIndex and targetIndex differently. Mark Guzdial


a)
def spliceTest():
   file = r"C:\filehere"
   source = makeSound(file)
   target = makeSound(file)
   sourceIndex=1
   for targetIndex in range( 40327, 55770):
      setSampleValueAt(target, targetIndex, getSampleValueAt(source, sourceIndex))
      sourceIndex = sourceIndex + 1
   play (target)
   return target

And that's my answer folks...let me know if i'm wrong or if amy's right.
Thomas Sobeck



Link to this Page