CS074: The Digital World

Lab 2


Due Wednesday, February 4


Here are several exercises using the Binary Editor, one involving altering text, the other altering, and synthesizing, audio.  In all cases you should submit the product (the altered text and wave files), and a writeup explaining EXACTLY what operations you perfromed to achieve the result.

1.  Take the text of 'The Telltale Heart' and modify it so that all letters are lower-case, and so that the only character used that is not a letter is the space character.  You should save the result as a text file with a different name.  Even though it is now all one long line, you should still be able to view it with the Text Editor, by using the Word Wrap option.

2. Take the audio file flute.wav, and modify it so that the second half is played before the first half.  Use the Save as Wave file option to save the result under a different name.  (This will attach the appropriate header to the file.)  It is not a bad idea to first remove the original 40-byte header (using the Delete control) before further processing the file.

This next one takes some explaining:  Our audio files use an 8-bit quantity to represent the amplitude of each sample, while a CD recording uses 16 bits:  Distinguish a larger number of different amplitude levels leads to better-quality sound.  What if we wanted to hear the effect of using fewer bits to represent each sample?  Here's an idea of how to do this---take the original file, divide each sample by 8, and then multiply each sample by 8.  If you start out with a sample value whose binary representation is, say,

          11011011

then division by 8 gives

          11011

(because the remainder is thrown away), and multiplication by 8 give


       11011000

The amplitude values have about the same magnitude as before, but there are fewer different levels distinguished:  in effect we are using 5 bits to represent each sample instead of 8. (If you didn't perform the step of multiplying by 8, then the sound would be much fainter, but we're still only using 5 bits of information.)

3. Try this out, using 5 bits as in the example, 6 bits, 4 bits, etc.  At what point is the sound quality noticeably worse than the original?  Save the results of your experiments using the Save As Wave file option, and name them appropriately (for instance flute4bits.wav, flute5bits.wav, etc.)

4. Create a synthetic sound.  For instance, if you had a sample file that had the value 0 for 1/1000 second, then 50 for 1/1000 sec, then 0 again for 1/1000 sec., etc., you would have a so-called square wave with a frequency of 500 hertz (since it goes through a complete cycle every 1/500 second).  Create a square wave approximately two second in duration with a pitch of approximately 100 hertz (which is rather low-pitched).  Save the result as squarewave.wav using the Save As Wave File option.

*4.  A harder alternative to 4: Create a square wave sound that gradually increases either in pitch, or in volume, or both.

What to hand in:  A zipped folder containing your .wav files from problems 2,3, and 4, your text file from 1, together with a document explaining carefully how you did all the problems.  You should also hand in a printout of this document.