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, Exercise 64
HtDP, Exercise 68
HtDP, Exercise 73
For the remainder of the lab, we’re going to be using the single-cycle waveforms generously provided by Adventure Kid. Add this to your definitions window:
(require rsound/single-cycle)
Read the documentation for these functions, and define a sound containing at least five synth notes, not all starting at the same time. Use at least three different synthesizer tones. Experiment!
Develop a data definition for an snote, representing a synthesizer note; it should contain the family, the spec (just a number), the pitch (represented as a midi note number), and the number of beats. Create four examples of snotes.
Develop the pitch-up function, that accepts a snote and a number and returns a new synth note whose pitch is higher by the given number.
Develop the snote->rsound function, that accepts a snote and a tempo (in beats per minute) and a pitch bump (a small midi note number to be added to every pitch) and returns the corresponding rsound. Be sure to follow the steps of the design recipe. Write your test cases first!
Use rs-append, rs-overlay, and snote->rsound to turn a bunch of snotes into a short song. It should have at least two notes playing at all times, and it should contain at least ten notes.
Write a song-gen-1 function that accepts a pitch bump and generates the song just like the previous one; the idea is that by supplying a pitch bump, you can alter the pitch of every note in the song. Note that I’m not asking you to ‘develop’ this function, so no test cases are required. It should return an rsound.
Write a song-gen-2 function that generates a song by calling song-gen-1 twice, once with a pitch bump of zero and onece with a pitch bump of 0.05, and then overlays the result. How does it sound? Write your observations in the form of a comment. Are there other pitch bump pairs that sound better?
Develop the arpeggiate function, that accepts a snote and a tempo and returns an rsound of the duration specified that includes four notes of one quarter the length, whose pitches are offset by zero, four, seven, and twelve half-steps. In other words, a small arpeggio.
Copy your earlier song, and change it so that each note is now transformed to an rsound using your arpeggiate function. How does it sound?