Prelab 7: Arrays & Making Sounds

1. Review background reading

2. Find sounds for audio collage

In lab, you will be combining clips from multiple sound files into one audio collage. Your files must be in WAV format.

You should find at least 3 sound files that you will combine and put them on your iPod. The names of your files should be something descriptive, so that the course staff and your classmates may have some hope of guessing the content of the files from the name.

Make sure you keep these files in the disk part of your iPod that should be accessible from in Windows Explorer or the Mac OS Finder.

3. Normalizing sounds

Th following function from class, maxSound, returns the value of the sample with the greatest amplitude. # returns the maximum value in a sound def maxSound(sound): currentMax = 0 # loop through all samples for samp in getSamples(sound): # for each sample, check to see if it is greater # than max, if so, set max to current sample value value = abs(getSample(samp)) if value > currentMax: currentMax = value return currentMax How can you use maxSound with changeVolume from Lab 6 to normalize a sound so that its sound is at the maximum level without clipping? Remember that sounds sample values can range from -32,768 to 32,767.










4. Review creating sound clips

Below is a function from the class, clip that will be used in lab.

# return a new sound clipped from "sound" # beginning at index start and ending at index stop def clip(sound, start, stop): diff = stop - start + 1 # length of new sound in seconds duration = diff/getSamplingRate(sound) duration = ceil(duration) newSound = makeEmptySound(int(duration)) targetIndex = 1 for sourceIndex in range(start, stop + 1): origSamp = getSampleValueAt(sound, sourceIndex) setSampleValueAt(newSound, targetIndex, origSamp) targetIndex = targetIndex + 1 return newSound How would this function be changed to modify the original (sound) rather than creating a new clip?










5. Appending Sounds

Below is a function from the class, append, that will be used in lab. # creates new sound that results from appending sound2 to sound1 def append(sound1, sound2): duration = getLength(sound1)/getSamplingRate(sound1) duration = duration + getLength(sound2)/getSamplingRate(sound2) duration = ceil(duration) target = makeEmptySound(int(duration)) # Copy over first sound (sound1) for targetIndex in range(1, getLength(sound1) + 1): setSampleValueAt(target, targetIndex, getSampleValueAt(sound1, targetIndex)) # Copy over second sound (sound2) for targetIndex in range(1,getLength(sound2)+1): setSampleValueAt(target, targetIndex + getLength(sound1), getSampleValueAt(sound2, targetIndex)) Explain how you would modify the code above to add 0.1 seconds of silence between the two sounds.










Comments?
Last modified: Fri Feb 29 22:48:55 EST 2008