DSP Lab 08
DSP Lab 08
LAB NO 08
OBJECT:
To process Audio using MATLAB.
TASK NO 1:
Write a MATLAB script to accomplish the following tasks :
a) Record your utterance of “We” & play it.
b) Record your utterance of “You” & play it.
c) Increase the amplitude of audio signal.
CODING:
fs=11025;
y=wavrecord(3*fs,fs,2,'double');
y=y*10;
wavplay(y,fs);
TASK NO 02:
Write a script to read any audio file and display the following information :
a) Number of Sample points
b) Sampling Rate
c) Bit Resolution
d) Time duration
CODING : RESULTS:
[y fs nbits]=wavread('chimes.wav') fs = 44100
[m d]=wavfinfo('chimes.wav') nbits = 16
t=54080/44100 d = Sound (WAV) file containing: 54080 samples in 2
channel(s)
t = 1.2263
TASK NO 03:
Write a script to record your utterance of “Today is my Birthday” and Appply the following
operations on the signal:
a) Multiply the signal by ‘-1’
b) Reverse the signal
c) Multiply the signal by ‘10’
d) Replace each sample by its square root
e) Replace each sample by its square
CODING:
fs=44100;
y=wavrecord(4*fs,fs,2,'double');
taskA
y=y*-1;
taskB
y=flipud(y);
taksC
y=y*10;
taskD
y=vpa(sqrt(y),3);
taskE
y=y.^2;
TASK NO 04:
Write a MATLAB script to record your voice with a sample rate of 23KHz and 8-bit
resolution. Resample the audio signal at 16KHz, 8KHz, 4KHz, 2KHz and 1KHz.
CODING:
fs=32000;
y=wavrecord(1*fs,fs,2,'uint8');
%taskA
wavplay(y,16000)
%taskB
wavplay(y,8000)
%taskC
wavplay(y,4000)
%taskD
wavplay(y,2000)
%taskE
wavplay(y,1000)
TASK NO 05:
Write a MATLAB code to resample audio signal of anew media file in such a way as that
new waveform has a sampling rate of 11025Hz. Plot these two waveforms and their absolute
difference using subplot.
CODING:
Fs=11025;
[y fs nbits]=wavread('Beep1.wav');
wavwrite(y,Fs,'B:\\Beep2.wav');
[y2 fs2 nbits2]=wavread('B:\\Beep2.wav');
subplot(2,2,1);stem(y); RESULTS:
subplot(2,2,2);stem(y2); 1 1
-0.5 -0.5
-1 -1
0 2000 4000 6000 8000 0 2000 4000 6000 8000
0.5
-0.5
TASK NO 06:
-1
0 1000 2000 3000 4000 5000 6000 7000 8000
Write a MATLAB code to resample audio signal of anew media file in such a way as that
new waveform has a sampling rate of 11025Hz. Plot these two waveforms and their absolute
difference using subplot.
CODING: RESULTS:
250
[y fs]=wavread('beep1.wav');
x=length(y);
f=(0:x-1)*fs/x;
200
Y=fft(y);
P=(abs(Y).^2)/x;
150
Power
plot(f,P);
xlabel('Frequency');
100
ylabel('Power');
50
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
Frequency 4
x 10
TASK NO 07:
Record and playback 5 seconds of 16-bits audio and sampled at 11025Hz.
CODING:
fs=11025;
y=wavrecord(5*fs,fs,2,'double');
wavplay(y,fs);