CS U216 -- Algorithms and Data Structures for Engineers

Assignment 6

Due 15 June, 2005 -- no extensions!!

Assignment 6 involves modifying the music.h file submitted for Assignment 5 so that it is useful for generating waveforms that may be written to a .wav file.

I have created a music.h file which allows a sequence of pitches to be used to generate a waveform. However, your assignment is to modify the Voice class to generate the tones. The difference is as follows. A Voice consists of a sequence of Notes, not a sequence of Pitches. Notes have durations, whereas Pitches do not have durations. Thus, when the music.h file that I have provided is used to generate tones, each tone is played for a fixed time. The music.h file that you submit, however, should play a Voice, and each Note in that voice should last an amount approximately equal to the duration member field of that Note (in seconds).

Requirements:


The lab examples web-page includes a number of files in the Lab 6 section that may be used to create .wav files.

If you copy all of the files listed in that section and compile them, the resulting program can be used to create .wav files. Copy driver.cpp into the file which has the same name as your project followed by .cpp. Copy each of the other files into a new file in your project with the same name as that which appears in the header block of that file.

When you run the program, it will prompt you for a file name. For convenience, you should end the filename in .wav. This will allow you to play the file with Windows Media Player or QuickTime. The program will write the .wav file in the current directory. You may then open "My Computer" and navigate to that directory. The .wav file should be visible. On my system, the .wav file appears with a Windows Media Player icon. On your system it may appear differently. Double clicking on the .wav file causes it to play (at least on my system).

The machines in the labs have no speakers. If you want to hear the sounds of your .wav file playing, you will need to use ear-phones.


Last updated 10 June 2005.