Lab 5
As before, when the text asks you to “develop” or “design” a function, you need to follow the steps of the design recipe. Write your test cases using check-expect. For this lab, make a copy of the template before you rewrite it into the correct solution, so that I can see what it looked like. Comment it out so that it doesn’t mess up the rest of the code.
HtDP 2e, exercise 129
Develop the data definition for list-of-sounds, that contains a list of sounds. Create at least two examples.
Define my-sounds to be a list of four sounds. Write an expression that extracts the third sound from this list. Don’t use the built-in third or list-ref functions on this problem, just the basic cons/first/rest.
HtDP 2e, exercise 135. Write your findings in the form of a comment.
Develop the function soundslen, that accepts a list of sounds and returns the total length (sum, in frames) of all the sounds in the list.
HtDP 2e, exercise 140
Using the prior function, develop revplay, that accepts a list of rsounds and a pstream and plays the sounds in reverse order by using pstream-queue. It should return a pstream. Rather than a check-expect, simply write an example of calling it, and use a comment to indicate what should be played.
Develop the function tones-list, that accepts a list of midi note numbers and a volume in the range 0.0 to 1.0, and produces a list of sounds created with piano-tone where each tone’s pitch comes from an element of the list, and all tones have the same volume, given by the original volume argument. Use rs-append* to listen to the result in the interactions window.