Both MATLAB4 and MATLAB5 let you dump sound data to the speaker using the "sound" command. You can read and write sound data from/to disk using "auread" and "auwrite". To learn more about these commands, type "help sound" or "help auread" in MATLAB.
Below is software written by SWRIMS and used at our workshops. If you have problems installing or using this software, please contact Alexander Perlis, aprl@math.arizona.edu .
Neither MATLAB4 nor MATLAB5 comes with support for recording sound. The function record.m does the trick. After saving it, type "help record" in MATLAB. (It works on our Sun workstations and on our Linux systems.)
The function stripnoise.m will take sound data and clip off noise and blank space from the beginning and end of the recording. (This is useful if you tell the record function (above) to record, say, 5 seconds, but the interesting part of the recording is shorter.) After saving it, type "help stripnoise" in MATLAB.
>> y=record(5); %
Record 5 seconds from mic
>> sound(y); %
Listen to the recording
>> plot(y); %
See a picture of the wave
>> y=stripnoise(y); %
Remove beginning and ending blank space
>> plot(y); %
See picture of modified sound
>> sound(y); %
Listen to modified sound
>> close; %
Remove the plot window
>> auwrite(y,'mysound.au'); % Save the sound to disk
>> clear; %
Clear MATLAB memory (sound is forgotten)
>> y=auread('mysound.au'); % Load the sound back
in
>> sound(y); %
Play the sound
Both MATLAB4 and MATLAB5 have telephone TouchTones pre-recorded. To see a nice built-in demo, type "phone" in MATLAB. To compare the different touchtone waveforms, try our touchtoneplots.m. After saving it, type "help touchtoneplots" in MATLAB.
We used this program a lot during our workshops. You can input sounds (via microphone or load from disk), use the mouse to define one period of the sound, see the resulting periodic data, calculate the associated Fourier series, and enable/disable individual Fourier coefficients (as well as play the corresponding harmonics through a speaker) to help compare the Fourier series to the original data. All of this in the single MATLAB file fourierworkshop.m. After saving it, simply type "fourierworkshop" in MATLAB. (The sound welcomeToFourier.au will be automatically loaded if you save a copy on your system. Also, both record.m and stripnoise.m are called; you need these only if you intend to record via microphone and then strip noise from start and end.)
In some of our demonstrations, we took a given recording (for example, bart1.au ), added noise (actually, just a couple of high-pitched tones) to it, and then showed how to remove the noise using the Fourier transform (among other things). Our addnoise.m will add noise to a given sound. After saving it, type "help addnoise" in MATLAB.
NOTE: The "noise" here is intentional noise; this is quite different from the noise (blank space or static) that is removed by stripnoise.m (see above).
It turns out that the touchtone sounds on a regular telephone are different from those on a cellular telephone. Because of its portability, we used a cellular phone at the workshop. One of our demonstrations is to have someone come up and record the dialing of a telephone number. Then the program identifycellular.m figures out the telephone number by correlating each button press against known cellular tones.
You need all the prerecorded cellular tones. Put them inside the matlab directory in a subdirectory called cellular (you'll need to create it). They are: cell0.au , cell1.au , cell2.au , cell3.au , cell4.au , cell5.au , cell6.au , cell7.au , cell8.au , cell9.au , cellpound.au , cellstar.au .
You also need the identification program identifycellular.m . After saving it, type "help identifycellular" in MATLAB.
Here's a bunch of example dialing recordings on which to run identifycellular: cellnumber1.au , cellnumber2.au , cellnumber3.au , cellnumber4.au , cellnumber5.au , cellnumber6.au . For example, after saving these, try identifycellular('cellnumber1.au') in MATLAB.