Principles Digital Audio and Video Assignment 2 ADIL SHAH 1600228 Q1 A Triangular
Principles Digital Audio and Video Assignment 2 ADIL SHAH 1600228 Q1 A Triangular
Q1 B SAW TOOTH
fs = 44100,
[y fs] = wavread('Saw Tooth');
plot(y);
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x);
Q1 C IMPULSE
fs = 44100,
[y fs] = wavread('Impulse');
plot(y);
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x);
Q1 D WHITE NOISE
fs = 44100,
[y fs] = wavread('White Noise');
plot(y);
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x);
NOISE Q1 E PINK
fs = 44100,
[y fs] = wavread('Pink Noise');
plot(y);
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x);
Q1 F DIAL TONE
fs = 11025,
[y fs] = wavread('Dial_tone');
plot(y);
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x);
Q1 G MISSILE
fs = 11025,
[y fs] = wavread('Missile');
plot(y);
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x);
Q1 H MUSIC
fs = 44100,
[y fs] = wavread('Music');
plot(y);
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x);
Q1 I SINES
fs = 16000,
[y fs] = wavread('Sines');
plot(y);
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x);
10
Q1 J SQUARE WAVE OF FREQUENCY 1000 HZ
i=1:1000;
for n=1:10000
if(mod(n,10)>=5)
y(n)=1;
else
y(n)=0;
end
end
fs = 10000;
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x)
11
Q3 SQUARE WAVE OF FREQUENCY 5 HZ AND AMPLITUDE 1
12
Phase plot for the first three harmonics
THE OSCILLATIONS IN THE PEAKS OF THE PHASE PLOT CLEARLY INDICATE THE DIFFERENCE BETWEEN
THE TWO HARMONICS
13
CODE
clear all
t=0:0.001:10;
for n=1:length(t)
if(mod(t(n),0.2)<=0.1)
y(n)=1;
else
y(n)=0;
end
end
%plot(y);
xmag = fftshift(abs(fft(y)))/length(y);
xph = fftshift(angle(fft(y)))/length(y);
a=-5000:1:length(xmag)-5000-1;
plot(a,xmag);
figure
plot(a,xph);
wo = 5;
x1 = (pi/2) + (sin(2*pi*1*wo*t))/((1*pi)/2) + (sin(2*pi*3*wo*t))/((3*pi)/2);
plot(t,x1);
14
Question # 2
[y fs] = wavread('audio1');
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x);
15
Fourier spectrum of second audio file.
Listening to audio one can slightly guess that it has two frequencies.
Moreover, Zooming into the plot makes it clear that there are two frequencies. The second peak is at
0.0025 with an amplitude of 0.25 which is 0.01 tunes the amplitude of the first peak.
clear all
fs = 8000;
[y fs] = wavread('audio2');
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
stem(x);