DSP Lab Experiment 09 - Group 02 - e
DSP Lab Experiment 09 - Group 02 - e
Faculty of Engineering
Department of Electrical and Electronic Engineering
Section: E Experiment : 09
Submitted By ID Number
SAYED MAHMUD 19-40600-1
TAMANNA SUMAIYA 19-40749-1
ANIKA BUSHRA 19-40708-1
SHAH MD. TANJILAL FARDIN 19-40737-1
MD. ASIFUR RAHMAN 19-39618-1
Figure 1, Figure 2 and Figure 3 are the spectrum of FIR lowpass filter, FIR highpass and FIR bandpass filter
respectively. Figure 4 is the waveform and frequency spectrum before and after filtering using lowpass
filter. The X-label in waveform figure is timeline while Y label is amplitude. In spectrum figure, X-label is
frequency while Y-label is amplitude. We applied this filter to the noisy signal. We can see that the high
component has been removed. Then we play back the sound. Figure 5 is the waveform and frequency
spectrum before and after filtering using highpass filter. We only heard some little voice. Because the
sound that we applied is almost consist of low components. Figure 6 is the waveform and frequency
spectrum before and after filtering using bandpass filter. We applied this filter to the noisy signal. In
frequency spectrum figure, the components besides two cutoff frequencies have been removed.
Reference(s):
1. John G. Proakis & Dimitris G. Manolakis, “ Digital Signal Processing – Principles, Algorithms and
Applications”, Prentice – Hall India, 3rd Edition.
Appendix
A1.
F1=7000;
F2=800;
F3=1000;
r1=2;
r2=60;
p1=1-10.^(-r1/20);
s1=10.^(-r2/20);
FF=[F2 F3];
ma=[1 0];
v=[p1 s1];
[A21,wA21,bt,Yp]=kaiserord(FF,ma,v,F1);
B21=fir1(A21,wA21,kaiser(A21+1,bt));
[h,w]=freqz(B21,1);
figure;
plot(w*7000*0.5/pi,abs(h));
title('FIR low pass filter','fontweight','bold'); grid; %
A2.
F1=8000;
F2=3000;
F3=2000;
r1=2;
r2=60;
p=1-10.^(-r1/20);
s=10.^(-r2/20);
FF=[F3 F2];
ma=[0 1];
v=[p s];
[A23,wA23,bt,Yp]=kaiserord(FF,ma,v, F1);
B23=fir1(A23,wA23,'high',kaiser(A23+1,bt));
[h,w]=freqz(B23,1);
figure;
plot(w*10000*0.5/pi,abs(h));
title('FIR high pass filter', 'fontweight', 'bold'); grid;
A3.
fp=[ 1000 2000];
f=8000;
n=20;
% Normalizing the frequencies
wp=(2/f).*fp;
%Calculation of filter coefficients
b=fir1(n,wp);
%Plotting the filter response
[H,f]=freqz(b,1,500,f);
plot(f,abs(H));
TITLE('FIR Bandpass Filter');grid on;
B1.[there is no wavread available in this version of Matlab, you have to use audioread and omit one of
the o/ps e.g. bits]
[y1,fs,bits]=wavread('dt_16bars_102rap.wav');
nor1=y1/max(y1);
sound(nor1,fs,bits);
data=round(32767*nor1);
%t1=fopen('data.dat','w');
%fprintf(t1,'1651 1 0 0 0\n');
%fprintf(t1,'%d\n',data);
%fclose(t1);
n=length(y1);
Noise=0.1*randn(size(y1));
s=y1+Noise;
S=fft(s,n);
normal=s/max(s);
cha=round(32767*normal);
pause(4);
sound(normal,fs,bits);
%ch=fopen('cha.dat','w');
%fprintf(ch,'1651 1 0 0 0\n');
%fprintf(ch,'%d\n',cha);
%fclose(ch);
F1=7000;
F2=1000;
F3=1100;
w1=2*pi*F2/F1;
w2=2*pi*F3/F1;
r1=1;
r2=50;
p=1-10.^(-r1/20);
q=10.^(-r2/20);
fp=[w1 w2];
mg=[1 0];
de=[p q];
[A21,wA21,beta,ftype]=kaiserord(fp,mg,de);
C21=fir1(A21,wA21,kaiser(A21+1,beta));
D21=fftfilt(C21,s);
sound(D21,fs,bits);
sound(D21);
E21=fft(D21);
figure;
subplot(2,2,1);
plot(abs(S), 'g');
title('signal spectrum before filtering', 'fontweight', 'bold');
grid; subplot(2,2,2);
plot(abs(E21), 'r');
title('signal spectrum after filtering', 'fontweight', 'bold');
grid; subplot(2,2,3);
plot(s); title('waveform before filtering', 'fontweight', 'bold');
grid;
subplot(2,2,4);
plot(D21);
title('waveform after filtering', 'fontweight', 'bold');
grid;
B2. .[there is no wavread available in this version of Matlab, you have to use audioread and omit one of
the o/ps e.g. bits]
[y,fs,bits]=wavread('dt_16bars_102rap.wav');
m=max(y);
normal1=y/max(y);
sound(normal1,fs,bits);
indata=round(32767*normal1);
n=length(y);
Noise=0.1*randn(size(y));
s=y+Noise;
S=fft(s,n);
normal=s/max(s);
chang=round(32767*normal);
pause(4); sound(normal,fs,bits);
F1=8001;
F2=4000;
F3=3200;
w1=2*F2/F1;
w2=2*F3/F1;
r1=1;
r2=100;
p=1-10.^(-r1/20);
q=10.^(-r2/20);
fp=[w2 w1];
mg=[0 1];
de=[p q];
[A23,wA23,BT,ftype]=kaiserord(fp,mg,de);
C23=fir1(A23,wA23,'high',kaiser(A23+1,BT));
D23=fftfilt(C23,s); sound(D23,fs,bits);
E23=fft(D23); figure; subplot(2,2,1);
plot(abs(S), 'g');
title('signal spectrum before filtering', 'fontweight', 'bold'); grid;
subplot(2,2,2);
plot(abs(E23), 'r');
title('signal spectrum after filtering', 'fontweight', 'bold');
grid;
subplot(2,2,3);
plot(s);
title('waveform before filtering', 'fontweight', 'bold');
grid;
subplot(2,2,4);
plot(D23);
title('waveform after filtering', 'fontweight', 'bold');
grid;
B3. .[there is no wavread available in this version of Matlab, you have to use audioread and omit one of
the o/ps e.g. bits]
[y,fs,bits]=wavread('dt_16bars_102rap.wav');
m=max(y);
normal1=y/max(y);
sound(normal1,fs,bits);
indata=round(32767*normal1);
n=length(y);
Noise=0.1*randn(size(y));
s=y+Noise; S=fft(s,n);
normal=s/max(s);
chang=round(32767*normal);
pause(4);
sound(normal,fs,bits);
F11=1200;
F12=3000;
Fc1=1000;
Fc2=3200;
Fa=2200;
w11=tan(pi*F11/Fa);
w12=tan(pi*F12/Fa);
w21=tan(pi*Fc1/Fa);
w22=tan(pi*Fc2/Fa);
w=w11*w12/w22;
bw=w12-w11;
w1=1;
w2=(w1*w12-w.^2)/(bw*w);
[A22,wA22]=buttord(w1,w2,1,50, 's');
[C22,a22]=butter(A22,wA22, 's');
D22=fftfilt(C22,s);
sound(D22,fs,bits);
E22=fft(D22);
figure;
subplot(2,2,1);
plot(abs(S), 'g');
title('signal spectrum before filtering', 'fontweight', 'bold');
grid;
subplot(2,2,2);
plot(abs(E22), 'r');
title('signal spectrum after filtering', 'fontweight', 'bold');
grid;
subplot(2,2,3);
plot(s);
title('waveform before filtering', 'fontweight', 'bold');
grid;
subplot(2,2,4);
plot(D22);
title('waveform after filtering', 'fontweight', 'bold'); grid;