In this exercise we'll use some of Horstmann's companion code to edit an uncompressed sound file in the WAV format.
Create a directory to hold the files you'll use in this workshop. From the terminal window you can use the command mkdir to do this, like: mkdir sound (this creates a subdirectory in the current directory)
Download the sample WAV file (right-click or control-click and save as) and save it in the directory you just made.
Our program modifies files in place, so let's make a copy:
cp samp1.wav samp2.wav
Now let's write-protect the first one, just so it doesn't accidentally get clobbered.
chmod 444 samp1.wav
Download sound.cpp and save it in your directory. The file, along with other supplementary source code, can be obtained from the Wiley website as directed in the text.
Now you are ready to work on the workshop.
Edit only the function process() in sound.cpp. The rest of the code does not need to be changed. The process() function allows you to directly edit the hexadecimal bytes that encode the sound stream. Each 2-byte pair represents a single "sample". Digitized sound encoding formats use a sequence of integer data to represent the sound. The sound file you downloaded is sampled at a rate of 8000 Hz, meaning that each second of digitized sound corresponds to 16000 = 8000 * 2 bytes. If you use the command ls -l (lowercase ells, not numeral ones) you can see the size of your wav file. Check that it is about 13 seconds long before proceeding.
Edit sound.cpp so that it cuts the volume by a factor of 4. Compile and check your work. Whatever sound player you have should play the wav format.
To get a fresh copy of the sample, do cp samp1.wav samp2.wav again. This overwrites your previous work!
Play with process() to get different effects. See what effect simple arithmetic operations have.
Try to achieve an echo effect as demonstrated by the instructor.
There is no submission for this workshop. Attendance and participation result in full credit.
Can't change a rubric once you've started using it.