Lab 3
Read the documentation for the "make-tone" function. Define a sound containing two overlaid tones whose frequencies are separated by 4 Hz. Next, define a sound containing two overlaid tones whose frequencies are separated by 2 Hz. Finally, define a sound containing two overlaid tones whose frequencies are separated by 1 Hz. Do you hear a "beating" between the two tones when you play them? How is the rate of the beating related to the difference between the two frequencies? Write your observations in the form of a comment.
Search the web to find the frequencies of the "C Major" scale from middle C up one octave. Define a sound that contains the notes of this scale, in sequence. See if you can avoid redundancy where possible.
Write code that computes the interval (ratio) between each pair of adjacent notes in the scale. How many different intervals are present? Write your observations in the form of a comment.
Note: I’m not asking you to write a function, or to abstract over the repeated math. You can just go ahead and write seven little expressions.
Do HtDP 2e, exercise 31
Do HtDP 2e, exercise 34
Do HtDP 2e, exercise 44 (and then use the copied code to make the tests pass).
Do HtDP 2e, exercise 48
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.
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. Read the documentation for the andplay function, which will be useful here.
Design an interactive "kick hat snare hat" program, that plays a sound each time a key is hit. The first key causes a kick, the second causes a closed hi-hat, the third causes a snare, the fourth another closed hi-hat. After this, these repeat: kick hat snare hat, kick hat snare hat, and so forth.
Hint: think first about what the state of the world should be.
Design an interactive "rhythm test" application, that tests your ability to place a sound evenly between kicks. It should play a kick drum every second, allow you to play a snare by hitting a key and evaluate your performance. More specifically: When you hit a key, the program should check to see if your keystroke was halfway between the two kicks (to the nearest 1/28 of a second). If so, it plays a ding. If not, it plays a closed hi-hat (c-hi-hat-1).