Lab 4
In this lab, use make-pstream and pstream-queue to trigger your sounds, so they don’t wind up on top of each other.
No design recipe steps are required unless the item says "develop", as in "develop a program" or "develop a function".
Also, the rsound library provides several functions like sine-wave and sawtooth-wave that ... are probably not helpful to you. Using these functions will lead you into the world of signals, and we haven’t covered that in lecture at all, at this point. I would advise you instead just to use the same setup in the lab that we did in Monday’s lecture (the code for this lecture appears online, on Piazza).
Using rs-read/clip, extract a sample from a song of about ten seconds.
Using functions you know, add that sound to itself, delayed by 10000 frames, and play the result. Use rs-scale to lower the volume to 0.5, so that it doesn’t distort.
Once again, add that sound to itself, delayed by only 10 frames. How does it sound? Try it with 10, 5, and 2 frames. Write a comment describing how they sound.
Using indexed-signal and signal->rsound and rs-ith/left (as in lecture), reverse the sound
Using the same two functions along with rs-ith/left, stretch the sound out by a factor of 2. Duplicate frames to stretch it out.
Using the same functions, compress the sound by a factor of 2. Skip every other frame to compress it.
Construct a sine wave of 440 Hz.
Next, multiply the sampled sound by that sine wave of 440 Hz.
Construct a sawtooth wave. This is a wave that goes from zero up to 1.0 in a smooth sloped line and then jumps back to zero again. Your wave should have frequency 300 Hz. That is, it should jump back to zero 300 times per second.
mulitply your sampled sound by a sawtooth wave.
construct a square wave. This should be 1.0 for a period of time, and then 0.0 for the same period of time, then continue to alternate between 1.0 and 0.0. It should complete a single cycle of high/low 250 times per second, making a wave of 250 Hz.
multiply the sampled sound by the square wave.
As a warmup for project 2, develop a program that shows a set of four empty circles. Hitting the "1" key toggles the first circle from empty to blue and back again. Hitting the "2" key toggles the second circle from empty to red and back again. Continue with the third and fourth circles mapping to the "3" and "4", keys, with the colors purple and green. Hitting any keys in any order should toggle the appropriate circles. So, for instance, if I start the program and hit keys 4, 2, and 4, then the second circle should be red, and the others should all be empty.