Lab 6
Note: you must follow the design recipe for any problem that asks you to develop a function, with the exception that functions that produce sounds may have comments indicating what they are to produce, rather than check-expects.
In order to make checking your lab easier, please put all of your work into one file. You can work with separate files if you like, as long as you combine them all when it comes time to show them to me.
- Here’s a data definition for the natural numbers:
; a nat is either ; - 0, or ; - one more than a nat Develop the template for this data definition, using the function name fun-for-nat.
Develop the function sum-of-squares, which accepts a nat and returns the sum of the squares of the natural numbers from the given nat down to zero. Use the template you designed in the previous problem.
HtDP 2e, Exercise 143
HtDP 2e, Exercise 147
Develop the data definition for a note, containing a pitch, represented as a frequency in Hz, and a duration, represented as a number of frames. Make at least three examples of your data.
Develop the data definition for a note-list, containing a list of notes.
Develop the function note-list->sound, that accepts a note-list and produces a sound, where each note is rendered as a sound using make-tone, and the resulting sounds are appended together using rs-append*.
Find a piece of sheet music, and represent at least four measurers of its melodic line as a note-list. Use note-list->sound to create a sound, and listen to it. If you like, you can use this copy of "Deep Blue". If you need help reading sheet music, ask for it!
Develop the function 5up/note that accepts a note and returns a new one whose frequency is multiplied by 1.5.
Develop the function 5up/notelist that accepts a notelist and returns a new one where every note’s frequency is multiplied by 1.5.
Develop the function octup/note that accepts a note and returns a new one whose frequency is multiplied by 2.
Develop the function octup/notelist that accepts a notelist and returns a new one where every note’s frequency is multiplied by 1.5.
Develop the function woggle/note that accepts a note and returns a new one whose frequency is decreased by 100 Hz.
Develop the function remap that accepts a notelist and a function like 5up/note or woggle/note and returns a new notelist where the given function has been applied to every note.