Professional Documents
Culture Documents
DSP Audio Final
DSP Audio Final
REPORT
ON
“APPLICATION OF FILTERS ON A
SOUND SAMPLE”
Submitted in partial fulfilment of the requirements for the partial completion of
DIGITAL SIGNAL PROCESSING
(16EC5DCDSP)
SUBMITTED BY:
AMITH P 1BM17EC010
Course instructor
LALITHA S
Assistant Professor, Dept. of ECE
Aug-Dec 2019
song.mp3
Here we pass the signal through a Butterworth lowpass filter in order to extract the bass of the
signal as bass of the song is below to 250Hz.
The pass band and stop band edge frequencies are 200 and 300 Hz respectively.The passband
attenuation is 1 dB and the stopband attenuation is 20dB.
To get the digital frequencies we divide the required frequencies by sampling frequency and
multiply by 2*pi.
The frequency spectrum is plotted.
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
subplot(2,1,1)
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
wp = 2*(200*pi/fs);
ws = (2*300*pi/fs);
[N,wn]= buttord(wp/pi,ws/pi,1,20)
[b,a]=butter(N,wn);
y1=filter(b,a,y);
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
audiowrite('C:\Users\Amith\Desktop\DSP_assignment\song_butter_worth_low_pass.wav',y1,fs)
Frequency Spectrum
low_pass.mp3
Here we pass the signal through a Butterworth highpass filter in order to isolate the high
frequency noise.
The pass band and stop band edge frequencies are 5500 and 5000Hz respectively. The passband
attenuation is 1 dB and the stopband attenuation is 20dB.
To get the digital frequencies we divide the required frequencies by sampling frequency and
multiply by 2*pi.
The frequency spectrum is plotted.
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
subplot(2,1,1)
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
wp = 2*(5500*pi/fs);
ws = (2*5000*pi/fs);
[N,wn]= buttord(wp/pi,ws/pi,1,20)
[b,a]=butter(N,wn,’high’);
y1=filter(b,a,y);
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
audiowrite('C:\Users\Amith\Desktop\DSP_assignment\song_butter_worth_high_pass.wav',y1,fs
)
Frequency Spectrum
high_pass.mp3
Here we pass the signal through a Butterworth bandpass filter in order to reduce both bass and
treble and to increase the base.
The pass band and stop band edge frequencies are [2500,5500] and [2000,5000]Hz respectively.
The passband attenuation is 3 dB and the stopband attenuation is 20dB.
To get the digital frequencies we divide the required frequencies by sampling frequency and
multiply by 2*pi.
The frequency spectrum is plotted.
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
subplot(2,1,1)
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
wp = [2*(2500*pi/fs), 2*(5000*pi/fs)];
ws = [2*(2000*pi/fs), 2*(5500*pi/fs)];
[N,wn]= buttord(wp/pi,ws/pi,3,20)
[b,a]=butter(N,wn );
y1=filter(b,a,y);
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
audiowrite('C:\Users\Amith\Desktop\DSP_assignment\song_butter_worth_pass.wav',y1,fs)
Frequency Spectrum
song_butter_worth_band_pass.mp3
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
subplot(2,1,1)
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
wp = [2*(2000*pi/fs), 2*(5500*pi/fs)];
[N,wn]= buttord(wp/pi,ws/pi,3,20)
[b,a]=butter(N,wn ,'stop' );
y1=filter(b,a,y);
%y1 = y1(1:100000,:)
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
audiowrite('C:\Users\Amith\Desktop\DSP_assignment\song_butter_worth_stop.wav',y1,fs)
Frequency Spectrum
song_butter_worth_band_stop.mp3
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
subplot(2,1,1)
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
wp = 2*(200*pi/fs);
ws = (2*300*pi/fs);
[N,wn]= cheb1ord(wp/pi,ws/pi,1,20)
[b,a]=cheby1(N,1,wn);
y1=filter(b,a,y);
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
audiowrite('C:\Users\Amith\Desktop\DSP_assignment\song_cheb_low_pass.wav',y1,fs)
Frequency Spectrum
cheb_low_pass.mp3
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
subplot(2,1,1)
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
wp = 2*(5500*pi/fs);
ws = (2*5000*pi/fs);
[N,wn]= cheb1ord(wp/pi,ws/pi,1,20)
[b,a]=cheby1(N,1,wn,’high’);
y1=filter(b,a,y);
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
audiowrite('C:\Users\Amith\Desktop\DSP_assignment\song_cheb _high_pass.wav',y1,fs)
Frequency Spectrum
cheb_high_pass.mp3
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
subplot(2,1,1)
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
wp = [2*(2500*pi/fs), 2*(5000*pi/fs)];
ws = [2*(2000*pi/fs), 2*(5500*pi/fs)];
[N,wn]= cheb1ord(wp/pi,ws/pi,3,20)
[b,a]=cheby1(N,3.wn );
y1=filter(b,a,y);
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
audiowrite('C:\Users\Amith\Desktop\DSP_assignment\song_cheb_band_pass.wav',y1,fs)
Frequency Spectrum :
cheb_band_pass.mp3
wp = [2*(2000*pi/fs), 2*(5500*pi/fs)];
[N,wn]= cheb1ord(wp/pi,ws/pi,3,20)
[b,a]=cheby1(N,wn ,'stop' );
y1=filter(b,a,y);
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
audiowrite('C:\Users\Amith\Desktop\DSP_assignment\song_butter_worth_stop.wav',y1,fs)
cheb_band_stop.mp3
FIR Filters
Hanning Low pass
Here we pass the signal through a FIR Hanning lowpass filter in order to extract the bass of the
signal as bass of the song is below to 250Hz.
Having the cut-off frequency. To get the digital frequencies we divide the required frequencies
by sampling frequency and multiply by 2*pi.
The frequency spectrum is plotted.
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
N=28;
wc=(2*250*pi)/fs;
h=fir1(N,wc/pi,hanning(N+1));
y1=filter(h,1,y);
audiowrite('C:\Users\Amith\Desktop\song_low_hanning.wav',y1,fs)
subplot(2,1,1)
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
Frequency Spectrum
song_low_hanning.mp3
Here we pass the signal through a FIR Hanning high pass filter in order to isolate the high
frequency noise. The higher cut-off frequency is of 5000Hz . To get the digital frequencies we
divide the required frequencies by sampling frequency and multiply by 2*pi.
The frequency spectrum is plotted.
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
N=28;
wc=(2*5000*pi)/fs;
h=fir1(N,wc/pi,'high',hanning(N+1));
y1=filter(h,1,y);
audiowrite('C:\Users\Amith\Desktop\song_high_hanning.wav',y1,fs)
subplot(2,1,1)
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
Frequency Spectrum:
song_high_hanning.mp3
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
N=40;
wc=(2*250*pi)/fs;
h=fir1(N,wc/pi,hamming(N+1));
y1=filter(h,1,y);
audiowrite('C:\Users\Amith\Desktop\song_low_hamming.wav',y1,fs)
subplot(2,1,1) plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)))
Frequency spectrum:
song_low_hamming.mp3
Code:
[y,fs] = audioread('C:\Users\Amith\Downloads\song.mp3');
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
N=28;
wc=(2*5000*pi)/fs;
h=fir1(N,wc/pi,'high',hamming(N+1));
y1=filter(h,1,y);
audiowrite('C:\Users\Amith\Desktop\song_high_hamming.wav',y1,fs)
subplot(2,1,1)
plot(psd(spectrum.periodogram,y,'Fs',fs,'NFFT',length(y)));
subplot(2,1,2)
plot(psd(spectrum.periodogram,y1,'Fs',fs,'NFFT',length(y1)));
Frequency Spectrum :
song_high_hanning.mp3