Lab 2:   Arithmetic of sounds
1 Playing sounds
6.1.1.5

Lab 2: Arithmetic of sounds

At the end of this lab, you should be able to - play sounds - manipulate sounds using simple operators - define simple functions on sounds - design and build simple interactive programs using the "world" model

As before, do all of your work in a single definitions window. When an exercise asks you to answer a question rather than develop a program (or in addition), use a comment to record your answer.

1 Playing sounds

Beside ding, there are a number of other drum sounds that are built into the sound library:

Try playing some of these, using play.

Now, do these exercises.

  1. Do HtDP 2e Exercise 2.

  2. Use F1 to read the documentation for rs-overlay. You may have to "clear" the filter in order to show this documentation.

  3. Use define and rs-overlay to define claps to be the sound that has clap-1 and clap-2 on top of each other. Then, use rs-append and silence to play the claps noise twice, separated by one second of silence. Note that you need a lot of silence–there are 44,100 frames in each second.

  4. Do HtDP 2e Exercise 4.

  5. Do HtDP 2e Exercise 10.

  6. Use the record-sound function to record yourself saying the words "Chicken", "Monkey", and "Duck". Use rs-write to save them as WAV files. Use F1 to read the documentation and discover how these functions work.

  7. Use rs-read and play to play your three sounds individually.

  8. Building on Exercise 10, create an expression that says "Chicken" if the image is tall, "Monkey" if it is square, and "Duck" if it is wide.

  9. Do HtDP 2e Exercise 16.

  10. Define the function stutter, that extracts the first quarter of a sound and appends it to itself four times. You’ll need to use clip, rs-frames, and rs-append to make this work.

  11. Do HtDP 2e Exercise 23.

  12. Do HtDP 2e Exercise 28.

  13. Using big-bang, develop a program whose "state" is the string "blue" or "red". It should display a rectangle of the color matching the state. When the user presses the space bar, it should toggle the world state between "blue" and "red". When the user presses another key, nothing should happen.

  14. Using big-bang, develop a program whose "state" is the time elapsed since the beginning of the program, which plays the kick noise every second, and the c-hi-hat-1 sound every time the user presses a key.