You are on page 1of 5

American International University- Bangladesh (AIUB)

Faculty of Engineering (EEE)

Course Name : Digital Signal Processing Lab


Semester : Spring 2019-20 Sec : E
Faculty : Dr. Md. Kabiruzzaman Marks: 20

Student Name: Adil Baksha Mridul Student ID: 18-37702-1


Final-Term

Assessment for:
P.05.3.P5 Create relevant resources for complex engineering problems using modern engineering tools.

Marking Rubrics (to be filled by Faculty)


Proficient Good Acceptable Unacceptable Secured
Category
[5-4] [3] [2] [1] Marks
Algorithm of the Algorithm of the Algorithm of the Algorithm of the issue
issue/problem to be issue/problem to be issue/problem to be /problem to be
considered critically is stated considered critically is considered critically is considered critically is stated
clearly and described stated, described, and stated, but description leaves without clarification or
Algorithm/Logic comprehensively, delivering clarified so that some terms undefined, description.
relevant information understanding is not ambiguities unexplored,
necessary for full seriously impeded by boundaries undetermined,
understanding. omissions.
Syntax of the programming Syntax of the programming Syntax of the programming Syntax of the programming
Coding/ Syntax language is most efficient language is correct and no language is 60% correct. language is erroneous.
and shortest. error is found.
Detail analysis of the Justified analysis is Relevant analysis is Analysis is irrelevant to the
problem solution is presented. described. problem solution.
Analysis presented. Correct
explanation is expected with
proper reference.
The whole report is The report is thorough, Information lacks depth. Vague, unclear.
Organization of exceptionally well-organized relevant and accurate Accurate but inadequate or Insufficient or irrelevant
the Report and very easy to understand. information to some extent. repetitive at times. information.
Total Marks
Comments:
(Out of 20 ):

Instructions:
Use the following code to record your voice and store it in MATLAB:

audio_signal=audiorecorder(8000,24,1); % sampling rate, sample precision in bits and no. of


channels disp('Start speaking.')
recordblocking(audio_signal,3) % Recording for 3 seconds
disp('End of recording')
play(audio_signal)
speech=getaudiodata(audio_signal); % Converting to a vector from an audio file
Problem 1: Use your own voice to record an audio and save the recorded sound as an audio file, load it into
MATLAB by following the instruction given above. Store the recording into the more usual vector of audio and
show a time-domain plot of your recorded sound sample.

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')

Problem %Problem 4(LPF)

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;
%......................

%signal spectrum using lowpass filter


SSULF=fftfilt(lowpassfilter,noiseworse
);
%signal spectrum using highpass filter
SSUHF=fftfilt(highpassfilter,noisewors
e);
%signal spectrum using bandpass filter
SSUBF=fftfilt(bandpassfilter,noisewors
e);
figure(8);
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
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

You might also like