| ||
Step 1: |
Connect the
cable from the DAQ card to J3-1 on the
rightmost interface module.
Plug the sound card cable
into J2-1.
| |
Step 2: |
Make sure your mixer amp is still in good working order. Connect the mixer output to A/D input 4 (pin 46 on the interface socket strip). |
| ||
Step 3: |
If you have disassembled your earphone driver amplifier, rebuild it. Replace the 8.2 k resistor with a 100 as shown below. Connect the sound card line output to the amplifier input. |
| ||
Step 4: |
Verify that the audio output is working
by playing this
test signal.
| |
Step 5: |
Load the Labview program "recorder".
This program will record four seconds of
a signal to a file.
| |
Step 6: |
Start the program by pressing the Run button or CTRL-R.
The
Ready
indicator on the panel should come on.
| |
Step 7: |
When ready to record, press the
RECORD
button.
Wait for the
Recording
indicator to come on
and speak
a significant phrase
(e.g. "Come here Mr. Watson, I want you.")
into the microphone.
You should see the signal on the
waveform chart as it is being recorded.
| |
Step 8: |
After four seconds the
Done
indicator will come on.
To save the signal to a file, press the
SAVE
button.
If you're not happy with what you recorded,
press
SAVE
anyway, and press
Cancel
in the file dialog.
| |
Step 9: |
You will get a dialog box entitled "Enter Filename".
Select the Desktop from the "Save in" menu at the top
of the box.
By default the file will be named "sig1.txt".
If you prefer a different name
enter it in the "File name" box.
| |
Step 10: |
Examine the recorded signal file by double clicking on its icon
on the desktop.
Answer "Yes" to the "error" message stating that
the file is too large for Notepad.
Note that the samples have been scaled so that their value
corresponds to the signal value in volts.
| |
Step 11: |
Make a second recording of whistling a tune, playing your flute,
or some other sequence of tones with a "simple" harmonic
structure.
Save this using a different file name
(e.g. "sig2.txt").
If you don't have a flute, and can't whistle, use the function generator to record several random frequencies between 200 Hz and 1000 Hz. |
| ||
Step 1: |
Load Matlab from the
Start menu by following the path Programs -> Matlab ->
Matlab.
| |
Step 2: |
Our signals were recorded with a sampling rate of 10 kHz.
We can save a little typing by defining a Matlab variable
for the sampling frequency:
>> Fs = 10000; | |
Step 3: |
Select "Import Data ..." from the File menu.
In the resulting dialog box, select "Desktop" from the
"Look in:" menu.
Double click on the file "sig1.txt" (or whatever you named
your recorded file).
| |
Step 4: |
You should now have a vector named "sig1" (or whatever the
name of your file was).
Play it back by typing the following command:
>> sound(sig1, Fs) | |
Step 5: |
Repeat steps 3 and 4 for your second signal (sig2). |
| ||
Step 1: |
Display the spectrogram of your signal:
>> specgram(sig1, 256, Fs) | |
Step 2: |
The number 256 in the above command is the length of the signal
chunk used in computing the Fourier transform.
For our sample rate of 10 kHz, this corresponds to a time
interval of 25.6 ms and a frequency resolution of about 40 Hz.
We can get finer resolution in time or frequency
(but not both at the same time) by decreasing or increasing this
number.
Try values of 128 and 512 and see what difference they make
in the spectrogram.
With 512 you should be able to see the individual harmonics of
the pitch frequency.
If you have a low pitched voice, you may be able to see the
individual pitch pulses with length 128.
Can you distinguish the voiced from the unvoiced sounds?
| |
Question 1: |
What are the time and frequency resolutions corresponding
to these transform lengths?
Does the appearance of the different spectrograms support your
answer?
| |
Hint: |
The
figure()
command allows you to display several plots or spectrograms
at one time.
The commands
>> figure(2)
will create a new plot window (Figure 2) and display the
new
spectrogram
in it.
To go back to figure 1, just type
figure(1).
| |
Step 3: |
The spectrogram is simply a concatenation of the spectra of
individual chunks of the signal, which we can compute
individually.
Use the time scale on the spectrogram to find a strong voiced
region of the signal
(say, for example at t=1.5 sec).
Since the sampling rate is 10 kHz, this corresponds to a
sample index of t*10000 (15000 in our example).
Extract a chunk of length 256 from the signal at this point:
>> chunk=sig1(15000:15255); | |
Step 4: |
Examine your chunk with the
plot
command:
>> plot(chunk) | |
Step 5: |
Now take the DFT of this chunk of the signal:
>> spectrum = fft(chunk); | |
Step 6: |
If we try to plot the spectrum in the "obvious" way,
plot(spectrum),
we will get a big surprise.
The spectrum is a complex valued sequence, and Matlab
plots complex functions as the real vs imaginary part.
A more satisfying picture can be had with:
>> plot(abs(spectrum)) | |
Step 7: |
Note that this plots both positive and negative frequencies.
To get a more traditional plot:
>> plot(abs(spectrum(1:129))) Can you see the shape of this curve in the spectrogram at the point where you took your chunk? The spectrogram uses a logarithmic scale for magnitude, so you might try
>> plot(log(abs(spectrum(1:129)))) or
>> semilogy(abs(spectrum(1:129))) | |
Step 8: |
Display the spectrogram of your "musical" signal
>> specgram(sig2, 256, Fs) Can you identify the individual notes in the tune? Different instruments have different harmonic structures: a flute has few harmonics, an oboe or trumpet has many, a clarinet has no even harmonics. Analyze the harmonic structure of your tones. |