[Note: this webpage last modified Friday, 04-Feb-2011 19:44:51 EST]
Adinistrative...
Homework 6 questions?
Survey
Final Project
Homework 5 not yet graded
Today: normalizing.
Warning about using sounds that you record with the sound recorder in Windows!
By default, Windows records the sound with 8 bits per sample. So what is the maximum and minimum possible values? 28 is 256 different possible values, with one of them being 0 (the baseline), 127 of them being positive, and 128 of them being negative. If you take an 8bit per sample sound file and load it into JES, it will still be an 8bit sound file. Try setting the first sample value to be 1000. Then do a getSampleValueAt(sound, 0) and see what it is now. Is it equal to 1000? If you loaded an 8bit per sample sound file, it won't be, because 127 is the maximum value.
Normalizing -- make it so the maximum sample in the sound is the maximum possible value (32767), and adjust the other samples accordingly so the sound still "sounds the same". So if the max sample started out being 32767/2, then we would multiply all the samples by 2.
Outline/plan of attack. First, compute the maximum sample of all the samples. This will be a for loop, keeping track of the "largest so far". Second, based off what the largest sample is, compute a multiplier that you want to multiply all the samples by. Third, have another for loop to multiply all the samples by the multiplier.
Work in pairs on this.
Clipping -- top and bottom of the sound curve is flat. May sound strange... First, try it with increasing the volume repeatedly. Second, we will make it so any sample is either the max value or the min value. This makes "square wave". So, have a for loop for every sample, and inside the for loop, if the sample value is greater than 0 set to 32767, if less than or equal to 0, set to -32768. Try it out on one of the sounds with someone talking. Can you still understand? Try it out on a note. What does it sound like now.
Note: can use writeSoundTo just like writePictureTo to save a sound you have created/modified into a wav file.
Next time - working just on different parts of a sound, and using arrays in Python.
And make sure to take the quiz, and type things into JES to try them out!