Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Digital Signal Processing (CE-405) SSUET/QR/114

LABORATORY 08:

AUDIO PROCESSING USING MATLAB

EXERCISE:

Task #1: Write a MATLAB script to accomplish the following tasks:

a. Record your utterance of "we" and play it backwards. Does it sound like "you"?

CODE:

Fs = 8000;
nBits = 16 ;
nChannels = 2 ;
ID = -1;
recObj = audiorecorder(Fs,nBits,nChannels,ID);

disp('Start speaking.')
recordblocking(recObj,2);
disp('End of Recording.');
play(recObj);

sigsound = getaudiodata(recObj);
filename = 'first.wav';
audiowrite(filename, sigsound, Fs)

[sf,Fs] = audioread('first.wav');
plot(sf);
sfRev = sf(end:-1:1)
plot(sfRev);
sound(sfRev,Fs);

SOLUTION:

NO

b. Record your utterance of "you" and play it backwards. Does it sound like "we"?

SOLUTION:

NO

c. Record your utterance of "We are you" and play it backwards. What does it sound like?

Page 1
-Department of Computer Engineering-
-Sir Syed University of Engineering & Technology-
Digital Signal Processing (CE-405) SSUET/QR/114

SOLUTION:

Cannot understand.

Task #2: Write a MATLAB script that can read the wav file "notify.wav" and display the following
information:

a. Number of sample points.


b. Sampling rate.
c. Bit resolution
d. Time duration of the recording (in terms of seconds)

SOLUTION:

Task #3: Write a MATLAB script to record your utterance of "today is my birthday". Try to explain the
playback effect you observe after you try the following operations on the audio signals.

a. Multiply the audio signals by -1.


b. Reverse the audio signals in time axis.
c. Multiply the audio signals by 10.
d. Replace each sample by its square root.
e. Replace each sample by its square.

SOLUTION:

CODE:

[y,fs]=audioread('first.wav');

subplot(3,2,1)
plot(y)
title('Orginal 2018-CE-067')

Page 2
-Department of Computer Engineering-
-Sir Syed University of Engineering & Technology-
Digital Signal Processing (CE-405) SSUET/QR/114

subplot(3,2,2)
plot(y*(-1))
title('Multiply by -1');

subplot(3,2,3)
plot(flipud(y))
title('Reverse')

subplot(3,2,4)
plot(y*10)
title('Multiply by 10');

subplot(3,2,5)
plot(y.*y)
title('Square wave')

Task #4: Write a MATLAB script to record your utterance with a sample rate of 32 KHz and 8-bit
resolution. Try to resample the audio signals at decreasing sample rates of 16 KHz, 8 KHz, 4 KHz, 2

Page 3
-Department of Computer Engineering-
-Sir Syed University of Engineering & Technology-
Digital Signal Processing (CE-405) SSUET/QR/114

KHz, 1 KHz, and so on. At which sample rate you start to have difficulty in understanding the contents of
the utterance?

SOLUTION:

CODE:

[y,fs]=audioread('first.wav');
audiowrite('first.wav',y,32000,'BitsperSample',8)
% x=audioinfo('first.wav')
y=audioread('first.wav');
X1=audioplayer(y(1:2:end),16000)
X2=audioplayer(y(1:2:end),8000)
X3=audioplayer(y(1:2:end),4000)
X4=audioplayer(y(1:2:end),2000)
X5=audioplayer(y(1:2:end),1000)
play(X1)
play(X2)
play(X3)
play(X4)
play(X5)

I was only able to understand the content of utterance at 4KHz

Task #5: Write a MATLAB script to resample the audio signals in "sunday.wav" such that new
waveform has a new sample rate of 11025. Plot these two waveforms and their absolute difference by
using subplot.

SOLUTION:

CODE:

[y,fs]=audioread('first.wav');
audiowrite('sunday.wav',y,11025);
[y1,Fs1]= audioread('sunday.wav');
% audioinfo('sunday.wav')
difference = y-y1

subplot(221)
plot(y)
title('first.wav 2018-CE-067')

subplot(222)
plot(y1)
title('sunday.wav')

Page 4
-Department of Computer Engineering-
-Sir Syed University of Engineering & Technology-
Digital Signal Processing (CE-405) SSUET/QR/114

subplot(223)
plot(difference)
title('difference')

Task #6: generate spectrum of above audio signal


SOLUTION:
Page 5
-Department of Computer Engineering-
-Sir Syed University of Engineering & Technology-
Digital Signal Processing (CE-405) SSUET/QR/114

Task #7: Record 5 sec of 16bit audio sampled at 11025 & play it.

SOLUTION:

Page 6
-Department of Computer Engineering-
-Sir Syed University of Engineering & Technology-
Digital Signal Processing (CE-405) SSUET/QR/114

Task #8: Repeat Task 1 and 2 with Fs = 10 KHz, 22 KHz and 44.1KHz for RINGIN.WAV file. It is
present in your root folder of Windows. Generate the following spectrum as well.

SOLUTION:

Task #9: What you have observed by looking at spectrums of different waveforms and listening sounds
with different frequency values. Is the spectrum looks same for more than one frequency or it changes?

SOLUTION:

Page 7
-Department of Computer Engineering-
-Sir Syed University of Engineering & Technology-
Digital Signal Processing (CE-405) SSUET/QR/114

What i observed is that by increasing the frequency the pitch of the sound was changed and there was no
change in spectrum with different frequencies.

Task #10: The Simulink model for human generated voice is present in theory section (figure 9.2).
Convert that Simulink model into MATLAB commands and write complete code for it.

SOLUTION:

Task #11: Proceeding task-10, observe human generated voice on different sampled frequencies.

SOLUTION:

Page 8
-Department of Computer Engineering-
-Sir Syed University of Engineering & Technology-
Digital Signal Processing (CE-405) SSUET/QR/114

Page 9
-Department of Computer Engineering-
-Sir Syed University of Engineering & Technology-

You might also like