Lab 14 (DSP Open Ended)
Lab 14 (DSP Open Ended)
Sharoze Sohail
Procedure:
1. Open M-file or M-Book
2. Save it by any useful name but remember not to start the name by any numeric digit, do not use
any special character other than under-the-score ( _ ) and also remember not to give any space
in the name.
Task I:
1. Read an audio signal from matlab toolbox using the command
[Y, FS]=audioread('audio48kHz.wav');
2. Now use factor as a variable for decimation & interpolation factor, assign it values as 4, 8, 16 ,
20. And using play command analyze the effect on sound quality as well as spectrum using the
following code.
factor = 8;
p = audioplayer(Y, FS);
play(p);
Yf=fftshift(fft(Y));
subplot(311),plot(linspace(-FS/2,FS/2,length(Yf))/1000,abs(Yf))
Y_dec=decimate(Y,factor);
p = audioplayer(Y_dec, FS);
play(p);
Yf=fftshift(fft(Y_dec));
subplot(312),plot(linspace(-FS/2,FS/2,length(Yf))/1000,abs(Yf))
Y_inter=interp(Y_dec,factor);
p = audioplayer(Y_inter, FS);
play(p);
Yf=fftshift(fft(Y_inter));
subplot(313),plot(linspace(-FS/2,FS/2,length(Yf))/1000,abs(Yf))
Task II:
1. For analyzing the Decimation and Interpolation system in a more detailed and preferable
manner Matlab Simulink will be used, for help certain step are described below.
a. Getting Started: Click the SIMULINK icon in toolbar as shown in figure beneath or type
SIMULINK in command window.
Electrical Engineering Department Instructor: Engr. Sharoze Sohail
c. Now open a SIMULINK *.slx file by clicking the New model icon as shown in figure above. The
model window is where your work by dragging the contents from SIMULINK library browser.
Electrical Engineering Department Instructor: Engr. Sharoze Sohail
.slx file
d. Now with the help of your teacher’s instructions design the following model (use sources & sinks
from DSP System Toolbox):
e. The above model is a designed for a 100 Hz signal with a sampling frequency of 1000 and 100
frames per second output, the results in the spectrum analyzer as in dBm Scale. Further details
will be given by the Lab instructor.
f. The output from the above spectrum analyzers will be as following:
Electrical Engineering Department Instructor: Engr. Sharoze Sohail
50
0
0
-50
-50
dBm
dBm
-100
-150 -100
-20
-40
dBm
-60
-80
-100
-120
RBW: 1.46 Hz, NFFT: 1537
-140 Span: 1.5 kHz, CF: 0 Hz
-600 -400 -200 0 200 400 600
Frequency (Hz)
UpSampled
g. As we can see we have not used any kind of pre or post filters so the spectrums especially in
case of up-sampler can be observed as tripled. If the M & L factors are changed from 2 & 3,
respectively, further disturbances might be noted.
h. Note: with the up-sampler and the down-sampler the frequency axis alters accordingly.
i. Adding a filter after, between and before or placing up-sampler first following down-sampler
with a filter in between will add more information for your analysis.
Task III:
2. The next and final task is to design an appropriate filter for final analysis.
a. For filter designing we will use the “fdatool”, type it in matlab command window and the
following window will appear.
Electrical Engineering Department Instructor: Engr. Sharoze Sohail
Questions:
1. In Task I, when changing the factor from 4 up till, what do you think happened? Explain the
theory behind this, listen to the audio file, did you notice any difference in the audio quality? If
so, what happened? What about the storage space it took? What happened to this signal in
frequency domain? What was expected to happen?
2. While using the Simulink model what do you think is the difference between the use of a down-
sample followed by up-sampler & up-sampler followed by a down-sampler?
3. What is the difference between use of pre, post & mid filter, for down-sample followed by up-
sampler?