lab11, CISC106, Fall 2006
(final lab of the semester)

Introduction

In this lab, we'll work with digital audio and cell arrays

In lecture on 11/15 and 11/17 we discussed translating text into Morse Code, first in ASCII (as an application of the concept of Cell Arrays in MATLAB)—then taking it a step further, and translating this into digital audio (as 500Hz Sine Wave Tones of specific durations.)

This lab gives you an opportunity to work with those files to get a bit more insight into how they operate.

This lab is very basic, so it is only worth 50 points. Basically, you are going to take some existing MATLAB files that can translate Morse Code only for the letters A-F, and modify them so that they can produce Morse Code for the letters in your first and last name.

You'll also modify the regression test script so that it tests the files on words that can be formed with the letters of your first and last name.

Special Note: Don't go beyond the scope of the assignment!

There is a temptation to "go further" and produce the Morse Code translation for the entire alphabet.

DON'T DO THAT!

Do ONLY the letters of your first and last name—Here's why.

I'm requiring you to do only the letters of your first and last name for a reason—to discourage improper collaboration. Doing the entire alphabet increases the usefulness of your code to others in the class, and raises the temptation to share code. By doing only the letters of your first and last name, your submission is particular to YOU.

TAs and the professor will be on the lookout for code copying. Don't put yourself at risk—do ONLY the letters of your first and last name, and don't share code with others.

Severe deductions if you fail to comply here

To ensure compliance with this requirement, a 10% deduction will be taken—up to 30%—will be made for each letter NOT in your first and last name. I don't mean to be harsh—but I do need to make sure each person is doing his/her own work.

Prerequisites

Look over the lecture notes from 11/15 and 11/17. Ask your TA and/or your professor about things you don't understand.

Also, review Section 7.2 in the MATLAB textbook, and also review Professor Conrad's notes about Section 7.2

Step-by-Step Instructions

Instead of calling these "steps" as in previous labs, I'm calling them "parts" to avoid confusion with the four "steps" of the design recipe: (1) contract, (2) examples, (3) body, (4) testing. We'll use those four "steps" in Part 3 —and we'll add a "fifth step", namely (5) application.

Part 1: Preparing your lab11 directory, and copying files you will need

Part 1a: Create a new subdirectory for lab11

Create a new subdirectory ~/cisc106/lab011, and make that your working directory.

If you are not sure how to do this, then review the instructions from lab03, steps 1a through 1d.

Part 1b: Copy the files needed for this week's lab

There are two ways to copy the files for this week's lab. Read over both methods before deciding which one to use.

  1. Download them from the web page http://www.udel.edu/CIS/106/pconrad/06F/labs/lab11
  2. If you are working on strauss, copy them directly from the directory /www/htdocs/CIS/106/pconrad/06F/labs/lab11

Part 2: Examining the example programs

As in past weeks, there is nothing to turn in for Part 2.

The work you do in part 2 of this lab is only for practice and learning. There is nothing to turn in from this part of the lab. But it is still important and required.

Part 2a: Work with the Morse code files

As we demonstrated in lecture, the file convertMorseAthruF.m can be used to convert text to Morse Code, provided that the text consists only of the capital letters A-F, and the space.

Try it out for yourself. Change directory into your lab11 directory (the one where you copied the files in Part 1b), and try executing the following commands. Make up your own words that can be made up only of the letters A-F.

>> cd ~/cisc106/lab11                               
>> !cp /www/htdocs/CIS/106/pconrad/06F/labs/lab11/* .
>> ls
A.wav                  convertMorseAthruF.m  testConvertMorseAthruF.m
A_BEAD.wav          morseSinWavSamples.m  testMorseSinWavSamples.m
FEED_ABBA_BEEF.wav  sineWavVector.m       testSineWavVector.m
approxEquals.m      testApproxEquals.m

>> convertMorseAthruF('DAD') 

ans =

--- . .   . ---   --- . .

>> convertMorseAthruF('A FAB BEAD')

ans =

. ---       . . --- .   . ---   --- . . .       --- . . .   .   . ---   --- . .

>> convertMorseAthruF('SAD DAD')   
??? Error using ==> convertMorseAthruF
Character "S" in position 1 is not permitted

>> 

Part 2b: Work with the Audio files

We demonstrated working with some audio files in lecture that can create sine waves of various frequencies. Try these out for yourself:

>> cd ~/cisc106/lab11
>> makeA440
>> makeCsharp
>> makeDaboveA220
>>

After executing these M-files, you should have audio files (.wav files) on your web page that you can play, at the web page:

For information on playing audio files on the Sun Rays, see the following web page:

Part 2c: Create an audio file of your own for some Musical Note (optional)

This part only makes sense to do if you have some musical background—otherwise you can just skip it.

As illustrated in lecture, given the frequency of a musical note:

Experiment with creating an audio file at a different pitch by changing the number of half steps in the example files makeCsharp.m and makeDaboveA220.m. Remember to modify the file names too.

Part 2d: Putting together the audio and the Morse Code

Look at the contents of the file morseSinWavSamples.m. This file defines a function that consumes a string of ASCII characters (in the same format that is output by convertMorseAthruF.m) and produces the sound samples for the dits and dahs.

The file testMorseSinWavSamples.m is a script that tests this. Note that this test is a bit different—to see if the test is successful, we actually have to listen to the file and see if the dits and dahs "sound" right. The script writes the files out to the current directory, then copies them over to a web directory so that the sound files can be played through a web browser.

>> testMorseSinWavSamples
A.wav should now be a Morse Code file containing
the Morse Code for 'A'
A_BEAD.wav should now be a Morse Code file containing
the Morse Code for 'A BEAD'
FEED_ABBA_BEEF.wav should now be a Morse Code file containing
the Morse Code for 'FEED ABBA BEEF'
>>

You should try running this file so that you can get comfortable with playing audio either on the Sun Rays, or on your home PC—preferably both. You'll need to be comfortable with that to complete Part 3—the part you have to do for credit.

Part 3: Writing your own version of the files

Introduction to Part 3 (overview)

Your task is to write a new M-file defining a function based on the M-file convertMorseAthruF.m, called something like convertMorseFREDSMITH.m

Inside the file, you'll build a Cell Array like the one in convertMorseAthruF.m, but you'll only convert the letters that are in your name.

For example, if your name was Lisa Simpson, your Cell Array would have entries for the Morse Code for the letters LISAMPON, plus the space. If you like, you can rearrange these in alphabetical order, (e.g. AILMNOPS) but it is not necessary—that that is necessary is to have the order of the Morse Code values in your cell array correspond with the order of the letters in the variable letters.

In the end, you should be able to convert all the letters of your name, plus any word, sentence or phrase made up only of those letters.

You'll also need to construct test file like testConvertMorseLISASIMPSON.m that is used to test the file. That file should test the file on at least three strings (as described below.)

Finally, you'll modify the testMorseSinWavSamples.m file to use those three tests, i.e. to create three sound files corresponding exactly to the three tests in your testConverMorseLISASIMPSON.m type file.

As you modify these files, let the steps in the Design Recipe be your guide:

Step 1—contract

Start by copying the convertMorseAthruF.m file to a file called convertMorseYOURFIRSTANDLASTNAMEHERE.m

Then, modify the contract part of the file. What is consumed and produced won't change much, but it will change slightly. The name of the function will change. Also, change the name, date, section number, etc.

Step 2 —examples

At this stage, change the examples. You should have three, following this pattern:

The web site http://wordsmith.org/anagram/ may be helpful in coming up with words and phrases from your name.

Work out the Morse Code by hand. Resist the temptation to write the program first and then let the program do it for you—that defeats the entire purpose of making these examples.

Step 3 —body

Now, change the body of the function. You won't have to change much—but you do need to know what you are doing.

Step 4 —testing

Now, create a test script testConvertMorseLISASIMPSON.m based on the test script testConvertMorseAthruF.m That file should test the file on at least three strings (the examples indicated at step 2 above.)

Finally, modify the testMorseSinWavSamples.m file to use those three tests, i.e. to create three sound files corresponding exactly to the three tests in your testConverMorseLISASIMPSON.m type file.

Part 4: Create a diary file lab11.txt to show your work.

Your diary file should contain the following:

  1. A listing of the three files you created or modified:
  2. At least one sample function call to convertMorseLISASIMPSON.m directly at the MATLAB >> prompt (e.g. >> convertMorseLisaSimpson('LISA');)
  3. A run of both of the files testConvertMorseLISASIMPSON.m and testMorseSinWavSamples.m

Be sure that the files created by your testMorseSinWavSamples.m script are readable on the web.

Part 5: Create a zip file lab11.zip

Following the instructions from lab10 step 6, create a file lab11.zip containing a subdirectory lab11, with the same three .m files you listed out in part 4 above.

Part 6: Upload and Submit your work on WebCT

Upload and submit the following files:


That's it for lab11!

Due Date: Friday Dec 1st, 11:55pm

Penalties for late submissions

 


Grading Rubric (50 pts total)

 

End of lab11 for CISC106, Fall 2006