While the project is designed so that you can do it without using arrays and pointers, you may use them if you like. However, my solution did not use any.
This assignment involves further development to a library of C++ routines stored in files wavLibrary.h and wavLibrary.cpp. You started developing this library in lab04b. This project continues this development.
In this project you will add several capabilities to this library, and then use the library in several main programs.
The project is divided into several stages. At each stage, you add a bit more capability to either the library (wavLibrary.h/wavLibrary.cpp) or to one or more of the main programs. At each stage, the total amount of credit you can possibly earn increases.
If you find that you are not able to complete the entire project, the intermediate stages provide places where you can stop, for partial credit. If you do decide to stop part way through, skip down to the Stage marked "Submission: creating your TAR file and updating your web page".
As with lab04b, when you are finished, there will be a series of ".wav" files that will show your final work. The links below show an example "before" and "after" group of .png files.
| Before your changes | http://udel.edu/~pconrad/cisc181/05F/wavFiles/proj1b.before |
| After your changes | http://udel.edu/~pconrad/cisc181/05F/wavFiles/proj1b |
The following table shows a summary of the various stages in the project,
what
each one
involves,
and
the
partial
credit
involved.
Detailed
instructions
follow
this
chart:
topic |
C++ files |
before |
after |
credit
(running total) |
Stage(s) |
|---|---|---|---|---|---|
| Morse code for CISC or CISC181 | morseCISC181.cc |
CISC181.wav ( Morse code for CISC only) |
CISC181.wav (Morse code for CISC181) |
40% (40%) | 1 (part of lab04b) |
| DTMF tones | dtmf123.cc, cantGetThrough.cc |
DTMF123.wav (DTMF signals for digits 123) | cantGetThrough.wav (dialed a number, got busy signal) | 10% (50%) | 2 (part of lab04b) |
| Morse code for SOS | morseSOS.cc |
Several, SOSrepeat_*_*.wav files contain only the letter S. | Several SOSrepeat_n_d.wav files each contain SOS repeated n times over d minutes. | 10% (60%) | 3 |
| Mary Had a Little Lamb | mary.cc |
mary.wav contains a fragment of "Mary Had a Little Lamb" | mary.wav contains the whole song. | 10% (70%) | 4 |
| new sound idea | newSounds.cc, wavLibrary.cc |
does not exist | demonstration of some new sound idea; see notes below. | 20% (90%) | 5 |
| Farnsworth timing | farnsworthCISC181.cc, wavLibrary.cc |
CISC181_5wpm.wav, CISC181_10wpm.wav, |
CISC181_5wpm.wav, |
10% (100%) | 6 |
As part of the project, in Stage 4, you need to come up with your own creative idea for generating sounds. You should post your idea to the project 4 bulletin board on WebCT, making sure no-one else is doing a project 4b with exactly the same idea. Your instructor will announce the deadline for posting these ideas (it will be several days in advance of the final project deadline).
What could your new idea be? Here are some suggestions:
There are many other possible ideas. Consult with your instructor for additional suggestions if you are stuck. If you are really really stuck, you might consider doing project1a instead!
The project is divided into seven (7) stages. Except for stage 7, which is done when you are ready to submit—and you can "skip to" if you give up before the end (see "partial credit", below)—you should do the stages strictly in order.
On the other hand, it is probably best to read over the entire assignment before starting to code stage 1, so you have some idea of where you are going. Don't let the size or complexity overwhelm you; working step by step, one stage per day, you'll have no trouble finishing on time if you start NOW.
If you decide not to complete all 6 stages, that's ok. I hope that all students will try to complete at least up through stage 5, but however far you get, be sure you at least submit what you have (for partial credit). Once you are ready to submit, skip to stage 7, where you will create a tar file of your project for submission.
So, with that advice, let's begin,
Create a directory ~/cisc181/proj1. (This directory is where your C++ code goes, and should NOT be under ~/public_html)
Copy the files from ~pconrad/public_html/cisc181/05F/work/proj/proj1b to your ~/cisc181/proj1 directory.
Do a "make clean", "make all", "make install". You should see that you now have a directory ~/public_html/cisc181/proj1 that contains WAV files created by your code.
They will resemble the files in the "before" directory for project1b.
The Makefile in this directory has several rules in it that will help you complete the project efficiently.
First, try typing "make all".
This will compile all the routines, and then run commands that create the WAV files.
Then, try typing "make install". That will create your ~/public_html/cisc181/proj1 directory, copy all your .wav files into that web directory, and set the permissions correctly.
Look at the contents of the Makefile, and try to understand the "make install" rule. The -p flag on the mkdir command makes sure that in case the directory already exists, no error message is created. the "-m 755" option builds a "chmod" for the directory into the mkdir command. Make sure you are familiar with both of those Unix commands for the next exam (ask your TA and/or your instructor for help if you are not sure.)
You'll need to make a few modifications to this Makefile as part of this project, so try to understand all the steps in the Makefile and what they do. Ask your TA for help during lab, and your instructor for help during lecture if you have questions. Your Anderson textbook also has information about Makefiles.
You mostly completed this Stage as part of lab04b. All that is necessary to get proj1 credit for this Stage is to convert your main program makeMorseCode.cc from lab04b into one called morseCISC181.cc that uses the wavLibrary.h/wavLibrary.cc/wavLibrary.o routines and the endian.h/endian.cc/endian.o routines.
I've done most of the work for you on that. Look at the file morseCISC181.cc. It resembles the "before" program from lab04b.cc; i.e. it only generates Morse Code for "CISC", not for "CISC181".
Your job is to add the code into morseCISC181.cc to generate the additional tones for 181.
Note that you'll also have to change the wavLibrary.cc and wavLibrary.h files to include routines to generate the Morse code symbols for 1 and 8 (following the example of the routines for the letters C, I, and S.)
The Makefile already has rules for compiling the morseCISC181.cc program; just type "make", and the files you've modified will be recompiled.
After you get a successful compile and link of the morseCISC181 binary, type "make install". This will run the program, and then copy the resulting WAV file to the appropriate web directory (your ~/public_html/cisc181/proj1 directory; if that directory doesn't already exist, the Makefile will create it for you using the command "mkdir -p ~/public_html/cisc181/proj1").
This stage is similar to stage 1; you are just updating the code from lab04b to use the wavLibary.h and wavLibrary.cc files. In this case, our programs are called dtmf123.cc and cantGetThrough.cc. The dtmf123.cc program is just there for you as an example. The cantGetThrough.cc program is one that you have to write yourself from scratch; the cantGetThrough.cc program in the example directory is just a "shell" for you to use to get started.
In this stage, you'll start with the file morseSOS.cc, which currently generates only the letter S in Morse code, one time, with a fixed ditDuration, and places the result in the output file.
You'll turn this into a program that takes exactly three command line arguments:
You should figure out some way to determine the dit duration and dah duration from n and d. Remember to leave the inter-word spacing between the repetitions of SOS.
You'll need to modify the lines of code that
The make install routine runs the program several times with different parameters. Currently, each of those will result in a file that contains only the letter S, with a dit duration of 0.1. That, of course, is not what we want. After your modification, each of those files will have the proper length, and contain the correct number of SOS repetitions.
This is a really easy stage in terms of what you have to do. The main reason it is here it to give you some additional ideas about what you could do for stage 5, and some example code to build on.
Take a look at the mary.cc program. It generates a wave file with some music in it... the first few lines of "Mary Had a Little Lamb". Your task: add the rest of the song.
You don't really need to know much about music to do this (it helps, but it isn't necessary). A comment in the file indicates that the musical notes in the file (so far) are as follows:
// E D C D | E E E (rest)| D D D (rest) | E G G (rest) |
The full musical notes of Mary Had a Little Lamb, which are listed below. (The word "rest" indicates one beat of silence in the music):
// E D C D | E E E (rest)| D D D (rest) | E G G (rest) | E D C D | E E E E| D D E D | C (rest)(rest)(rest)
Since the current file only contains the first four bars (each bar is four beats), you should be able to look at the pattern and figure out what to do to finish the song.
The writeNote() function is particularly interesting. By varying the way the writeNote() function is written, we can change the sound of the music. Currently, the writeNote() function writes a small amount of "white noise" (a random waveform) at the beginning of each note. This gives the sound a bit of the "whoosh" that you get when you blow across the mouthpiece of a flute (or a soda pop bottle.) You can also make the notes more "staccato" (really short) or "legato" (long and smooth) by varying the ratio between the sound and the silence. The only restriction is that the coefficients of the beatDuration should add up to 1.0.
void writeNote(int fd, double beatDuration, double freq) { writeNoiseSamples(fd, 0.1 * beatDuration, 0.5 ); // 0.5 is the volume writeSineWaveSamples(fd, 0.4 * beatDuration, freq ); writeSilenceSamples(fd, 0.5 * beatDuration); }
You don't have to do anything to the writeNote() function for this stage. However, you might try experimenting with different kinds of writeNote() functions as part of your "new sound idea" in the stage that follows this one.
For a general overview of what you must do, re-read the section "The New Sound Idea" near the beginning of this project description first.
This stage is an update of the Morse code stages (1-3). The file farnsworthCISC181.cc is currently nearly identical to morseCISC181.cc. Your job is to read the comments near the bottom of the file about Farnsworth timing (as well as perhaps doing some reading on the web) and then modifying the program to produce the Morse Code output with the proper Farnsworth timing (expressed in words per minute.)
As an extra challenge, I'm not providing step-by-step instructions for this stage; I'm only giving you a description of the goal. The goal is that when you are done, the files produced by the "make install" step called CISC181_5wpm.wav, CISC181_10wpm.wav, and CISC181_20wpm.wav will all contain CISC181 in proper Morse code at 5 words per minute, 10 words per minute, or 20 words per minute, using the Farnsworth timing rules described in the comment at the bottom of the source code for farnsworthCISC181.cc.
Scripting your work and creating your tar file should follow the techniques learned in lab04b, so refer back to that lab for details. Here is a summary of what is required of you:
ls -lh to
see how large each file is in bytes, KB, MB, or GB.)Here is a summary of the grading rubric. TAs might indicate more detailed grading in their own rubrics.
| Stage | Item | Points | Running Total |
| final | correctly creating tar file in final submission. tar file should not contain .o or executable files (i.e.you should do a "make clean" before creating it.) | 10 | 10 |
| all | C++ style issues throughout: | 10 | 20 |
| all | correctly scripting and following instructions generally (includes having web links to proj1 directory). | 10 | 30 |
| 1 | CISC181.wav contains Morse code for CISC181 | 10 | 40 |
| 2 | cantGetThrough.wav contains sounds for dialing a number, getting a busy signal | 10 | 50 |
| 3 | Several SOSrepeat_n_d.wav files each contain SOS repeated n times over d minutes. | 10 | 60 |
| 4 | mary.wav contains the whole song, Mary Had a Little Lamb | 10 | 70 |
| 5 | Some new sound idea (a new song, a new sound, or something else.) | 20 | 90 |
| 6 | CISC181_5wpm.wav, CISC181_10wpm.wav, CISC181_20wpm.wav all use Farnsworth timing | 10 | 100 |