Professional Documents
Culture Documents
USMAN GHANI
BEE 4B
02-133182-014
SIGNAL AND SYSTEM
CEP
1
USMAN GHANI BEE 4B 02-133182-014
QUESTION NO: 01
%Record your voice of 8kHz for 16 seconds.
%recObj = audiorecorder (F's, nBits, NumChannels)
a= audiorecorder (8000,8,1);
disp('start speaking')
% recordblocking (OBJ, T)
recordblocking (a, 16);
disp('End of recording')
play (a);
myrec= getaudiodata (a);
figure; plot (myrec);
audiowrite('melody.wav',myrec, 8000);
(A)
figure;
[x, fs]= audioread('melody.wav');
plot (x)
sound (x, fs);
subplot (3,1,1);
plot (x)
title('time domain original sound ')
xlabel('time[s]')
2
USMAN GHANI BEE 4B 02-133182-014
ylabel('signalx[n]')
y = fft (x);
N=length(y);
f=(0: (N-1))*8000/N;
subplot (3,1,2);
plot (f, abs(y))
title( 'DET magnitude spectrum')
xlabel('F(Hz');
ylabel('amplitude');
fshift = (-N/2:N/2-1)*(fs/N);
yshift = fftshift(y);
subplot (3,1,3)
plot (fshift,abs(yshift))
title('shifted fft Magnitude')
xlabel ('F(Hz)');
ylabel('amplitude')
3
USMAN GHANI BEE 4B 02-133182-014
(B);-
figure;
fs1=128000; %fs=length of x(my audio signal)
f=3900;
t=0:1/fs:16;
n=0.5*cos(2*pi*f*t(1:end-1)');
plot(n);
title('noise signal')
xlabel('F(Hz)');
ylabel('amplitude');
figure;
xn= x+n;
sound(xn)
plot(xn)
title('noise in Audio signal')
xlabel('time[s]')
ylabel('noise contaminated signal xn [n]')
figure;
xn1=(20*log(abs(fft(xn))));
plot(xn1)
title('Dft spectrum magnitude in dB')
xlabel('f[Hz]');
ylabel('20*log10[X(k)][dB]' );
4
USMAN GHANI BEE 4B 02-133182-014
5
USMAN GHANI BEE 4B 02-133182-014
Part C;-
figure
rp=0.5; %passband attenuation
rs=80; %stopband attenuation
fp=(3600*2)/fs; %passband frequency
Fs=(3900*2)/fs; %bansstop frequency
[o,wn]=buttord(fp,Fs,rp,rs); %this command gives order and cutoff frequency
[q,p]=butter(o,wn);%'o' is order of filter here.
[h,w]=freqz(q,p,t);
plot(w,20*log(abs(h)));
xlabel('f[Hz]');
ylabel('20*log10|X(k)|[dB]');
figure;
xf=filter(q,p,xn); %it will filter the noise of the signal.
sound(xf,fs) %listen to filtered audio signal.
plot(xf) %plot filtered audio signal
title('Filtered Signal')
xlabel('time[s]');
ylabel('FilterDesign xf[n]');
6
USMAN GHANI BEE 4B 02-133182-014
PART D;-
In order to improve the performance of a Butterworth second
order filter for audio signal. Yes we can use the similar
filter twice in cascade design. Because the performance of
Butterworth signal depends upon the order of filter the
higher the order the finest the signal will be. So when we
cascade the 2nd order signal, its order will become 4th so
the performance of Butterworth filter will definitely
improve.
7
USMAN GHANI BEE 4B 02-133182-014
QUESTION NO: 02
(A)
8
USMAN GHANI BEE 4B 02-133182-014
9
USMAN GHANI BEE 4B 02-133182-014
10
USMAN GHANI BEE 4B 02-133182-014
(B)
K = 10;
Q = 10;
f = 10:10:10000;
w=2*pi*f;
R1 = 3160;
R2=1100;
R3 = 3090;
R4=6190;
R5=6190;
C1= 0.0000001;
w0=(2*Q)/(C1*R1*K);
B=w0/Q;
s=w*1i;
Gw=(K.*B.*s)./(s.^2+B.*s+w0.^2);
semilogx(f,abs(Gw));
axis([500 2000 0 10]);
grid;
hold on;
xlabel ('Frequency , Hz');
ylabel('[Vout/Vin');
title ('2nd order butterworth band pass filter responce')
11
USMAN GHANI BEE 4B 02-133182-014
Explanation of Plot :-
The frequency response of a system is simply its
transfer function as evaluated by substituting s =
jω. we can separate H(jω) into its magnitude called
amplitude response and its phase component called phase
response.
12