Lab exercise #2. 9/14/98
Spectral analysis and filtering.
The goal of this exercise is to understand the types of manipulations that are possible with the available tools such as MATLAB. You will need a sound board and software that supports recording with a microphone. An example is Creative labs "wave Studio". Both PCs in room 87 MSC are set up to accomplish this.
Start/ programs/accessories/multimedia/record: you are now set to record a speech fragment. Click on the icon with the red dot (record button). A window will come up that let's you see what level you are speaking into the microphone at. When you are ready to speak you have to click on start.
Alternate: Click on start/programs/accessories/entertainment/sound recorder.
Then file/properties/convert format/ choose 11kHz, mono, 16 bit. OK.
Then record.
say 'shoo cat' or what ever you like.
Click on stop.
2. Either record the waveform in 16-bit mono, and 11000Hz sample rate or use a convert format. Note MATLAB 5.0 handles 16-bit ".wav" files. It is best to have a relatively short sample ~1-2 seconds since it will affect the analysis time. You could have up to 10 seconds of signal if you are willing to wait. However, if MATLAB has to use the disc for large file and/or variables we may not hear from you again. You can use the cursors to select a portion of the displayed waveform (Creative Labs software). cut it, do file NEW, then paste. One can also do these operations later in MATLAB
3. Use save as to write the waveform as shoo_cat.wav in the c:\ neuro730\yourfolder directory.
4. At this point you can use the Creative Soundlabs package to explore what happens to the sound as you manipulate it in various ways (play the sound after every manipulation): try inverting the waveform, add an echo, reverse the waveform, try the fade-in, etc. (hint: try the special menu). You can also use the cursor to select any portion of the waveform and then display/play only that portion, e.g., a single word or a vowel.
5. exit and startup MATLAB.
y=wavread(‘shoo_cat’);
sf=11000;
to play out the sound: sound(y,sf,16);
you can vary the sample rate and replay the sound:
try sf = 9000, & then sf = 13000;
7. filtering: there is an m-file titled filtspa that will perform filtering of the signal: both low pass and high pass.
copy an .m file called filtspa.m, located in c:\neuro730 to your folder. Change line 3 so that your version of shoo_cat or whatever will be read in.
do cd c:\neuro730\yourfolder;
filtspa
follow the instructions. The results will be played out and the spectra displayed. This uses a particular filter called a Butterworth (5th order). There are several types of filters available that you could explore if you desire. The corner frequency can be varied to achieve different amounts of filtering from either the high or low frequency end of the spectrum. You could use both the high and low pass features to obtain a 'bandpassed' signal.
8. spectrogram: It will be obvious that a fourier analysis of this signal provides a limited picture of what the instantaneous energy vs frequency distribution. One way around this limitation is to perform the analysis on a short portion of the signal at a time (maybe 5 to 20 ms epochs) and to analyze the entire time signal in this manner. Study the spectrogram. If you have a ripple pattern as a function of frequency over some epoch what might be the cause of it?
Another display that is often used is the waterfall display: you can vary the angle at which the 3D display is shown by the use of the view command; try it by typing view (-37, 75). You could also see what happens if you convert the data to use a log scale: try b=10*log10(b + 1); then waterfall(t',f',b); It takes a little time to redisplay the graph.
There is also a contour plot that is generated.
There are a variety of displays that one can look at: mesh(b), surf(b).
you can get help on any of these by typing: help mesh, etc.
******to complete this exercise plot both the time waveform and the spectrogram. Annotate the spectrogram: what portion of the spectrogram corresponds to each portion of the time signal. Explain what you see in the spectrogram. Hand in.
9. listen to the CD: "Hair Cells And Hearing Aids" that is already loaded in the CD ROM. Tracks 6 thru 17 give an indication of how several types of hearing losses would affect the perceived sound. Use the CD wizard or CD player (exit MATLAB) to select the tracks and play the sounds.
e.g.
click on START\programs\multimedia\CD player
\select: track 6
\play.
What frequency loss appeared to most affect your ability to understand the speech?
Note MATLAB is case sensitive: this means be careful with upper/lower case.