| CPSC 120 | Principles of Computer Science Using Multimedia Design |
Spring 2009 |
In this lab, we will write more computer programs for manipulating sounds. As with the previous lab, you will need ear phones in order to hear the sounds that you are transforming or have transformed. IMPORTANT: USE CAUTION WHEN TESTING OUT A MODIFIED SOUND. PLAY THE SOUND WITH THE EAR PHONES A FEW INCHES AWAY FROM YOUR EARS TO MAKE SURE THAT IT IS NOT TOO LOUD. If the sound is at a reasonable volume then you can put the ear phones in your ear and play the sound again.
Here are the exercises for this week's lab. There are 3 required exercises. They are due in lab next Friday (at the start of lab). You should write the functions for the exercises below in a single Python file called exercises.py within the lab10 folder within your cs120 folder on your desktop.
Make sure you comment all of your code as described in lab 3. This will be an important part of your grade. Important: make sure you provide a comment describing how the function should be called so that I can execute the function as you do. Also, make sure you put all sound files that you use in this lab in your lab10 folder so that I have access to them (you will also need to copy some of them to your www folder so that they can be put on your web page).
Write a function for creating an echo in a sound of spoken text. Unlike the function shown in class, your function should include a parameter (in addition to the sound parameter) for specifying the offset between the original sampled values and the echoed sampled values (in class we used a fixed value of 10,000).
Use your function to create an echo in a sound with some spoken text. Use a different sound then the "this is a test" sound, which was used in class. In exercise 3, you will put this sound on your web page.
Write a function called incrAndDecr for creating an increasing volume effect in the first half of a sound (like a crescendo) and a decreasing volume effect in the second half of a sound (like a decrescendo). Your function should take one sound as a parameter and return a new sound (note: don't modify the original) with the increasing/decreasing effect.
You will use this function to create a sound with a crescendo in the first half of the sound and a decrescendo in the second half. You will put this on your web page in exercise 3.
Put the sounds that you created in the earlier exercises on your cs120 web page (cs120.html). These should include the echoed sound and the increasing/decreasing sound from exercises 1 and 2, respectively. To save each of them, use the function writeSoundTo (see the kJES help or lab 8 for information on how to use writeSoundTo). You will add them to the table in cs120.html within your www folder.
To add them to your web page you will create a link within a table cell that refers to the corresponding sound file. Most browsers will know how to play the wav file if the user clicks the link (if not the user can download the file and then play it using an application that does understand wav files -- like kJES). For example, here is how a link tag might look in your web page:
<a HREF="increase-freq.wav">Increased Frequency</a>
This would allow the viewer to play a wav file called increase-freq.wav (that wav file would need to be copied to www) by clicking on the link.
Here is my version of cs120.html. Your page should look similar.
|
|