Lab 4: A few functions
Here’s a simple program that plays a note:
(require rsound) |
(require rsound/utils) |
; given a note, produce a sound containing a pure 1-second tone |
(define (note pitch) |
(make-tone pitch 0.1 44100 44100)) |
(play-rsound (note 440)) |
This program defines a new function, note, that saves us the trouble of typing make-tone over and over again.
First, use the note function to define a short song. Perhaps "Mary Had a Little Lamb?"
Next, define a new function, arpeggio, that accepts a pitch and produces a new sound that plays the given pitch, then a note a major third above it, then the note a fifth above it, then the octave.
This is nice, but the length of the note is fixed. Define a note/d function that accepts both a pitch and a duration, and produces a sound playing the given note for the given number of frames.
Now, define arpeg/d that is like arpeggio but also accepts a duration.
Use these new operators to play a song.
If you finish, ask me for more!
1 Sound operators
Here are the sound operators we know about:
read-rsound : string -> rsound |
write-rsound : rsound string -> (void) |
play-rsound : rsound -> (void) |
rsound-clip : rsound number number -> rsound |
rsound-append* : (listof rsound) -> rsound |