0% found this document useful (0 votes)
39 views

Principles Digital Audio and Video Assignment 2 ADIL SHAH 1600228 Q1 A Triangular

This document contains code and analysis of various audio signals including triangular waves, sawtooth waves, impulses, white noise, pink noise, dial tones, and music. Fourier transforms and plots are generated for each signal. Additional code generates a square wave at 5 Hz and plots the Fourier spectrum and phase plots of the first three harmonics. Code is also included to generate a square wave at 1000 Hz and plot its Fourier spectrum. Finally, two audio files are analyzed by plotting the Fourier spectrum and listening to determine the number of frequencies present in each file.

Uploaded by

ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Principles Digital Audio and Video Assignment 2 ADIL SHAH 1600228 Q1 A Triangular

This document contains code and analysis of various audio signals including triangular waves, sawtooth waves, impulses, white noise, pink noise, dial tones, and music. Fourier transforms and plots are generated for each signal. Additional code generates a square wave at 5 Hz and plots the Fourier spectrum and phase plots of the first three harmonics. Code is also included to generate a square wave at 1000 Hz and plot its Fourier spectrum. Finally, two audio files are analyzed by plotting the Fourier spectrum and listening to determine the number of frequencies present in each file.

Uploaded by

ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

1

PRINCIPLES DIGITAL AUDIO AND VIDEO


ASSIGNMENT 2
ADIL SHAH 1600228
Q1 A TRIANGULAR
fs = 44100;
[y fs] = wavread('Triangular');
plot(y);
sound(y,fs);
x = fftshift(abs(fft(y)))/length(y);
plot(x);

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

FOURIER SPECTRUM OF THE SQUARE WAVE

12
Phase plot for the first three harmonics

Phase plot of first six 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);

Fourier spectrum of first file.


Listening to audio and plotting the spectrum shows that it contains only one frequency.

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

You might also like