0% found this document useful (0 votes)
51 views6 pages

DSP Assignment

This document is an assignment to add and remove noise from an audio signal. It reads in an audio file, plots the left and right channels. Noise is added and the original and noisy signals are plotted in the time and frequency domains. Noise is then removed using averaging and Gaussian filtering. The processed signal is plotted and written to a new file.

Uploaded by

namish pruthi
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)
51 views6 pages

DSP Assignment

This document is an assignment to add and remove noise from an audio signal. It reads in an audio file, plots the left and right channels. Noise is added and the original and noisy signals are plotted in the time and frequency domains. Noise is then removed using averaging and Gaussian filtering. The processed signal is plotted and written to a new file.

Uploaded by

namish pruthi
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

Assignment

Add and remove noise from an audio signal

Department Of Information Technology


UNIVERSITY INSTITUTE Of ENGINEERING AND
TECHNOLOGY
PANJAB UNIVERSITY, CHANDIGARH

Submitted to: Submitted by:


Dr. Sukesha Sharma Namish Pruthi(UE168069)
Assistant Professor
Information Technology
UIET, Panjab University
%Reading Audio File
[f,fs] = audioread(​'[Link]'​);

% Determine total number of samples in audio file


N = size(f,1);
fig = figure;

%Plotting Left Channel


stem(1:N, f(:,1));
title(​'Left Channel'​);
saveas(fig,​'Left [Link]'​)

%Plotting Right Channel


stem(1:N, f(:,2));
title(​'Right Channel'​);
saveas(fig,​'Right [Link]'​)

%Adding Noise to the Audio Signal


fn = f + 2*randn(length(f),1);
%Plotting Time domain of Original Signal
time=(1/fs)*length(f);
t=linspace(0,time,length(f));
plot(t,f);
title(​'Time domain plot of Original signal'​);
saveas(fig,​'original_td.jpg'​)

%Plotting Time Domain of Signal with Noise


time1=(1/fs)*length(fn);
t1=linspace(0,time1,length(fn));
plot(t1,fn);
title(​'Time domain plot of Noise Added Siganl i.e fn.'​);
saveas(fig,​'noise_td.jpg'​)

 
%Plotting Frequency of Original Signal
N=length(f);
Fc=(-N/2:N/2-1)/N;
F=fs*Fc;
wa=fft(f);
wa=fftshift(wa);
plot(F,wa);

title(​'Frequency plot of Orignal Signal'​);


saveas(fig,​'original_f.jpg'​)

%Plotting Frequency of Signal with noise


N1=length(fn);
Fa=(-N1/2:N1/2-1)/N1;
F1=Fa*fs;
wq=fft(fn);
wq=fftshift(wq);
plot(F1,wq) ;title(​'Frequency plot of fn.'​);

saveas(fig,​'noise_f.jpg'​)

sound(fn,fs);

%Noise removal
i=1;
%Averaging for reducing intensity of high frequencies
for ​j=2:N1-1
f(j,i) = (f(j-1,i) + f(j,i) + f(j+1,i))/3 ;
end

g = gausswin(20);​%Creating Gaussian window of 20


g = g/sum(g);
y= conv(f(:,1), g, ​'same'​); ​%Applying Conv to filter added noise
audiowrite(​'[Link]'​,result,fs); ​% resultant signal can be written to the
new file
%Plotting Frequency plot after removing noise
Nn=length(result);
Fn=(-Nn/2:Nn/2-1)/Nn;
Fq=fs*Fn;
new=fft(result);
new=fftshift(new);
plot(Fq,new); title(​'Frequency plot after removing Noise'​);
 

You might also like