Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
This lab is common to EBU6018 and EBU5303.
Part 1 (Questions 1 to 4) of the lab is a revision of the Discrete Fourier Transform (DFT), the Fast Fourier Transform (FFT), and an introduction to the Short-Time Fourier Transform (STFT) and to spectrograms. Marks will go towards the assessment of EBU6018.
Part 2 (Questions 5 to 7) is a guided exploration of the characteristics of speech sounds. Marks will go towards the assessment of EBU5303.
The MATLAB programming outcomes from the lab (i.e., MATLAB .m function files and plot figures) are to be handed in as a “folder” of results, showing that you have completed the steps of the lab successfully.
You must also answer some questions directly within this document, which must be saved and submitted with other outcomes in your folder of results.
You must submit your combined report to BOTH EBU6018 AND EBU5303 QM+ course areas.
Getting Started
In your home directory, create the subdirectories “MULTIMEDIA_Y3_Sem1” and “MULTIMEDIA_Y3_Sem1/lab1”.
Download all the resources needed for the lab (i.e. audio files) in “lab1”.
Start Matlab. Use “cd <directory>” to get into the directory “lab1” you have just created.
In Matlab, type “edit” to start the Matlab editor.
Part 1 (EBU6018)
1. Discrete Fourier Transform
a.Create a Matlab function in the file “dft.m” to calculate the Discrete Fourier Transform of a signal. Recall that the DFT is given by [e.g. Qian, eqn (2.34) and course notes]
Hints:
? Start your function with: function sw = dft(st)
where “st” is the time waveform vector, and “sw” is the frequency waveform vector
? Matlab vectors (e.g. st and sw) start from 1, not zero, so use “n-1” and “m-1” to refer to the appropriate element
? Assume that N=M, and use the “length(st)” to find the value to use for these.
An example outline for your DFT Matlab function is provided below.
b.Generate some waveforms to test your function. Test your dft on the following four signals:
? Uniform function: “s=ones(1,64);”
? Delta function: “s = ((1:64)= =1);”
[NB: “1:64” generates the vector (1 2 … 64) ].
? Cosine wave: “s = sin(((1:64)-1)*2*pi*w/100)” for various values of w (at least two different values, one of which should be ω=12.5).
Why do we need to use “(1:64)-1”?
What values of w give the cleanest dft?
What happens if we use “cos”?
? Symmetrical rectangular pulse: “s = [0:31 32:-1:1]<T” for various values of T.
(NB: Why doesn’t this “look” symmetrical? Remember that the DFT repeats, so the time interval 32 .. 63 is “the same as” the interval -31 .. -1).
The following function may be useful to display your results:
If you want zero frequency (or time) to appear in the middle of your plot, use “fftshift”, e.g. “stem4(fftshift(dft(s)));”
2. Comparison with Matlab’s FFT function
Matlab has a built-in Fast Fourier Transform, “fft”.
a.Compare the results of your dft against the built-in fft. Are the results the same? If so, why: if not, why not?
b.Find out the complexity of your dft and the built-in fft, i.e. how long they take to perform their calculation for various lengths of s. Use “tic” and “toc” to measure the time taken to perform the operation, so e.g.
tic; dft(ones(1,4)); toc % No “;” for final expression
will report how long a 4-point DFT took to calculate.
Hint: You may find your dft is too fast for tic/toc to measure any useful difference. If so, run it several times, e.g.
tic; for (i=1:1e4) dft(ones(1,4)); end; toc
(Of course, remember to divide your measure by the number of times round the loop!)
c.Make a log-log plot (using “loglog”) showing the time increase with the size n of s.
On your plot, show that the DFT takes O(n2) time, while the FFT takes O(n log n).
Hint: Use “hold on” if you want to add a second “loglog” plot to an existing plot.