mkdir cse20211/lab8 cd cse20211/lab8Read about the Simple Sound Library and try out the example program, which generates a single note.
Code | Action |
---|---|
a | Play A-flat: 415.30 Hz |
A | A: 440.00 Hz |
b | B-flat: 466.16 Hz |
B | B: 493.88 Hz |
C | C: 523.25 Hz |
d | D-flat: 554.37 Hz |
D | D: 587.33 Hz |
e | E-flat: 622.25 Hz |
E | E: 659.26 Hz |
F | F: 698.46 Hz |
g | G-flat: 739.99 Hz |
G | G: 783.99 Hz |
. | Play a rest (silence) for the length of the current note type. |
+ | Play one octave higher. (double frequency of all notes) |
- | Play one octave lower. (halve frequency of all notes) |
1 | Change the current note length to a whole note. (two seconds) |
2 | ... a half note. (one second) |
4 | ... a quarter note. (half a second) |
8 | ... an eighth note. (1/4 of a second) |
6 | ... a sixteenth note. (1/8 of a second) |
X | End of song - stop the program. |
When the program starts, the default note length is one quarter note. The default tempo is two quarter notes per second. Each note is a simple sine wave at the desired frequency.
Any white space in the input should be ignored. Any other character not listed above should cause the program to emit a useful error message and continue processing data.
When you run the program, it should simply read in one character at a time from the console and write out the desired notes to music.wav. For testing, you can type in the music at the keyboard. Even better, you can put the music text into a file example.music and then run this command:
piano < example.musicwhich will cause the text input to be read from example.music automatically and generate the file music.wav.
Turn in piano.c and synth.c. (Do not turn in any WAV files, as we will test your program's ability to create them.) Your lab report should explain how the synthesizer waveform was constructed, and what you intend for it to sound like.
This assignment is due on Monday, Nov 11th at noon. Late assignments are not accepted.