Professional Documents
Culture Documents
Assessment for:
P.05.3.P5 Create relevant resources for complex engineering problems using modern engineering tools.
Instructions:
Use the following code to record your voice and store it in MATLAB:
Problem 2: Show the frequency domain response of the data by using the function freqz() in MATLAB by
choosing the range of ω from 0 to π.
Problem 3: Now add a white Gaussian noise to your recorded audio sample by using the function awgn(input
signal, SNR). Use two different values for SNR (in dB) which indicates the quality of the channel
characteristics, i.e. one good channel and one bad channel. Plot the noisy signal for two different values of
SNR and observe the outputs. Which output is better? Justify your answer.
Problem 4: Now design three different filters; LPF, HPF and BPF to pass this noisy signal and remove the
noise. Choose the cutoff range from the frequency response curve of your voice signal. Plot the frequency
response curve of all your filters and the filtered signals. Which filter output is better for your sound processing
system?
* There are many predefined window types for the filters in common use, and with different characteristics
(that are adequately explained in most signal processing textbooks). Use any one type of window for designing
your filter.
FIR Filters
1. Rectangular
2. Bartlett
3. Hann
4. Hamming
5. Blackman
6. Kaiser
Problems Codes
Problem clc;
1 clear all;
audio_signal=audiorecorder(8000,24,1)
; disp('Start speaking')
recordblocking(audio_signal,3)
disp('End of recording')
play(audio_signal)
speech=getaudiodata(audio_signal);
figure(1)
subplot(111)
plot(speech)
title('Problem1: Time domain');
Page - 2
Problem w=0:pi/200:pi;
2 [h,w]=freqz(speech,1,w);
figure(2)
subplot(212)
plot(w,abs(h))
title('Frequency Domain')
Problem noiseworse=awgn(speech,30);
3 noisebetter=awgn(speech,70);
subplot(211)
plot(noiseworse)
title('Worse Channel')
figure(3) subplot(212)
plot(noisebetter)
title('Better
Channel')
4 F1=7000;
F2=800;
F3=1000;
r1=1;
r2=50;
p=1-10.^(-r1/20);
q=10.^(-r2/20);
fp=[F2 F3];
mg=[1 0];
de=[p q];
[A21,wA21,beta,ftype]=kaiserord(fp,mg,
de,F1);
lowpassfilter=fir1(A21,wA21,kaiser(A21
+1,beta));
Page - 3
[h,w]=freqz(lowpassfilter,1);
figure(4);
plot(w*7000*0.5/pi,abs(h));
title('FIR low pass filter');
xlabel('frequency')
ylabel('magnitude')
grid on;
%high pass
F2=3000;
F3=2000;
mg=[0 1];
[A23,wA23,beta,ftype]=kaiserord(fp,mg,
de,F1);
highpassfilter=fir1(A23,wA23,'high',ka
iser(A23+1,beta));
[h,w]=freqz(highpassfilter,1);
figure(5);
plot(w*10000*0.5/pi,abs(h));
title('FIR high pass filter');
xlabel('frequency')
ylabel('magnitude')
grid on;
%Bandpass filter
F =[1000 1300 2210 2410 ]; % cutoff
freq
mg=[0 1 0];
devs=[0.01 0.05 0.01];
[n,wA23,beta,ftype]=kaiserord(F,mg,dev
s,F1);
n=n+rem(n,2);
bandpassfilter=fir1(n,wA23,'bandpass',
kaiser(n+1,beta),'noscale');
[h,w]=freqz(bandpassfilter,1,1024,F1);
figure(6);
plot(w*10000*0.5/pi,abs(h));
title('FIR band pass filter');
xlabel('frequency')
ylabel('magnitude')
grid on;
%signal spectrum using lowpass filter
SSULF=fftfilt(lowpassfilter,noisebette
r);
%signal spectrum using highpass filter
SSUHF=fftfilt(highpassfilter,noisebett
er);
%signal spectrum using bandpass filter
SSUBF=fftfilt(bandpassfilter,noisebett
er);
figure(7);
subplot(411),
plot(noisebetter)
title('signal spectrum before signal')
xlabel('frequency'),ylabel('magnitude'
)
grid on;
subplot(412),plot(SSULF),title('signal
spectrum after signal by
lowpass'),xlabel('frequency'),ylabel('
magnitude'),grid on;
subplot(413),plot(SSUHF),title('signal
Page - 4
spectrum after signal
highpass'),xlabel('frequency'),ylabel(
'magnitude'),grid on;
subplot(414),plot(SSUBF),title('signal
spectrum after signal
bandpass'),xlabel('frequency'),ylabel(
'magnitude'),grid on;
%......................
Comments:
It can be said that the actual result was found from those signal spectrum output.From those three filters, Low
Pass Filter (LPF) gave us better signal than High Pass Filter(HPF) and Band Pass Filter(BPF).Here, I used FIR
filter as ‘Kaiser’ for more accurate result.So, Low Pass Filter(LPF) was much better for my sound processing
system.
Page - 5