Homework 6

[Note: this webpage last modified Friday, 04-Feb-2011 19:44:51 EST]

This assignment will be handed out at the end of class on Wednesday, September 29 and is due (electronically submitted) before class starts on Wednesday October 6.

Please download the template file from hw6.py. You can put your answers into this file, and then turn in this file either as an attachment to an email or uploaded in blackboard. This is the way we will to it from now on - I will give you the template file, and you put your answers in. If you do not turn in your homework in this way, I will take off points!

    1. (5 Points) Download the following sound file and load it into JES: hw6-1.wav. What is the sampling rate of this sound file?

    2. (5 Points) What is the value of the very last sample in this sound file?

    3. (5 Points) What is the number of samples in one cycle of the hw6-1.wav sound, approximately?

    4. (5 Points) Use the sampling rate and number of samples in one cycle of hw6-1.wav to determine the frequency in the tone in this sound file. What is the frequencey?

      Look at the table at the website http://en.wikipedia.org/wiki/Piano_key_frequencies to determine what note the tone is. What note is the tone?

  1. (5 Points) CD quality sound uses a sampling rate of 44100 hertz, uses 16 bits to store a sample, and is a stereo format (a separate sample is stored for left and right speakers - so a single "sample in time" uses 32 bits). "Radio quality" sound uses a sampling rate of 22050 hertz, uses 8 bits to store a sample, and is a mono format (so a single "sample in time" uses 8 bits).

    How many bytes does it take to store a sound file that is 3 minutes long in CD quality? How many bytes does it take to store a 3 minute sound file in radio quality?

  2. (5 Points) Middle C on a piano should theoretically be tuned to be 261.626 hertz. Typical humans can hear sounds ranging from 20 hertz to 20000 hertz. How many different C notes are there that can heard by typical humans? (Note that a standard 88 key piano has 8 different C notes.)

  3. (EXTRA CREDIT 5 Points on the Exam) Write a function called stripesBW that takes as input a width and height and creates a picture of those dimensions that has stripes of black and white that are each 5 pixels tall. This was problem 9 on the exam. If you called "stripesBW(300, 50)" in the command area, you would get a picture that looks like this:

  4. (EXTRA CREDIT 5 Points on the Exam) Write a function called redGreenPic that takes as input a picture and converts it to a "red and green picture". This would be just like black and white, except we want to use the colors red and green instead. So a pixel should be set to red if its brightness is at least a certain value that you pick (say 135), and should be green if its brightness is below that value. This was problem 10 on the exam. If you called the redGreenPic function, and use a threshold of 135, with the banner at the top of this page (which you can get from ../include/banner.jpg), then you would get a picture that looks like this: