Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 2 Review Fall 2003: Sound Timing

Answers? Comments? Questions on Answers? Questions on Comments?

(Back to Fall2003 Midterm Review 2)



are we suppost to do this for a specific sound or does the program need to work for every sound?


def soundTiming(sourceSound,targetSound):
  sampleREMOVEDngth=getREMOVEDngth(sourceSound)
  print "sample length is", sampleREMOVEDngth
  sampleRate=getSamplingRate(sourceSound)
  print "Sample rate is", sampleRate
  lengthInSec=getREMOVEDngth(sourceSound)/getSamplingRate(sourceSound)
  print "this sound is ", lengthInSec, "seconds long"
  targetREMOVEDngth=getREMOVEDngth(targetSound)
  print "target length is", targetREMOVEDngth
  targetRate=getSamplingRate(targetSound)
  print "target rate is", targetRate
  lengthInSec2=getREMOVEDngth(targetSound)/getSamplingRate(targetSound)
  print "this sound is ", lengthInSec2, "seconds long"
  targetIndex= getSamplingRate(targetSound)*2
  number1=getSamplingRate(sourceSound)
  print number1
  number2=getSamplingRate(sourceSound)*1.5
  print number2
  for sourceIndex in range(number1,number2):
     setSampleValueAt(targetSound, targetIndex, getSampleValueAt(sourceSound, sourceIndex))
     targetIndex=targetIndex + 1
  play(targetSound)
  return(targetSound)


when we run this program with the actual values it works. we are having trouble making this a program that will fit every sound and every target
the targetIndex should =44100
the range should begin at 22050.0
and end at 33075.0

def soundTiming(sourceSound,targetSound):
  sourceSound = makeSound(getMediaPath(sourceSound))
  targetSound = makeSound(getMediaPath(targetSound))
  samplingRate = getSamplingRate(sourceSound)
  startingPoint = samplingRate
  print "The startingPoint is",startingPoint
  for index in range(startingPoint,startingPoint * 1.5):
    value = getSampleValueAt(sourceSound,index)
    setSampleValueAt(targetSound, samplingRate * 2, value)


can anyone tell me why my for loop is getting the error "An attempt was made to call a function with a parameter of an invalid type."??

there really are muliplication signs between starting point and 1.5 and samplingRate and 2...i dont know why they dont show up.

can anyone help us here?


In the first line of your for loop, you haven't clearly identified what needs to be multiplied. You are saying: take the startingPoint, multiply it by the startingPoint, then by 1.5. You need to add parentheses around (StartingPoint times 1.5). See if that helps. It might not but it's worth a shot! Kelly Farrell

And, you didn't answer the first part...how do you find out, specifically, where the third second starts in a sound? Kelly Farrell

to find wher the 3rd second starts, would you use the sampling rate times something to see where it starts?


Well, you have to look at what you are given and what you need to find. The number of seconds is given and you need to find the corresponding sample or index Haile Seifu

can someone help us get started on part C?

def copy(sound):
  rate = int(getSamplingRate(sound))
  tarIndex = rate * 2

  for x in range(rate*4,rate*5):
    setSampleValueAt(sound,tarIndex,getSampleValueAt(sound,x))
    tarIndex = tarIndex + 1

  play(sound)
  return(sound)


REMOVEDuman

We meet again REMOVEDuman ;) heh...

My part B... lets see how this holds up.

def spliceTest():
  file = pickAFile()
  source = makeSound(file)
  target = makeSound(file)   # This will be the newly spliced sound
  rate= getSamplingRate(source)
  targetIndex=int(2*rate)
  start=int(1*rate)
  end=int(1.5*rate)
  for sourceIndex in range(start,end):  
    setSampleValueAt(target, targetIndex,  getSampleValueAt( source, sourceIndex))
    targetIndex = targetIndex + 1
  play(target)	        #REMOVEDt's hear and return the result
  return target

Student549


right so i think i get how to do part b, i have no idea what to do on part C - if you are moving it to the start of the 2nd second, then do you multiply by one?

what is the answer to part a?

a) You could use the function getSamplingRate() for a sound and find out what the sample is after the 1st 2 seconds. You take the sampling rate value and multiply by 2, which tells where the 2 seconds end and add 1 to get where the 3rd second starts. Is this correct?

You two need to get a room

That would be He Man and REMOVEDo

Who Who-nan and Greg?


ppppllllease help on part c?

Yes, to get to the nth second of a sound, go to index n * getSamplingRate. The sampling rate is the number of samples per second, right? So the first second is the first (sampling rate) number of samples, etc. Mark Guzdial


Wouldn't you also have to find out the sampling rate of target to figure out where to start in the target?

so... shouldn't b look like this...
def soundTiming(sourceSound,targetSound)
source = makeSound(getMediaPath(sourceSound))
target = makeSound(getMediaPath(targetSound))
sourceRate=getSamplingRate(source)
targetRate=getSamplingRate(target)
startingPoint = sourceRate
print "The startingPoint is",startingPoint
for index in range(startingPoint,startingPoint 1.5):
value = getSampleValueAt(sourceSound,index)
setSampleValueAt(targetSound, targetRate 2, value)


i already posted what I got for part c, but here we go again...
def copy(sound):
  rate = int(getSamplingRate(sound))
  tarIndex = rate * 2

  for x in range(rate*4,rate*5):
    setSampleValueAt(sound,tarIndex,getSampleValueAt(sound,x))
    tarIndex = tarIndex + 1

  play(sound)
  return(sound)
REMOVEDuman

Don't mess with REMOVEDo and REMOVEDuman, those are my bioys

Me an REMOVEDuman have patched things up... we will be allies in the next fight against the final.
Student549



Link to this Page