Professional Documents
Culture Documents
INTRODUCTION
All real measurements are disturbed by noise. This includes electronic noise, but can also include
external events that affect the measured phenomenon — wind, vibrations, the gravitational attraction
of the moon, variations of temperature, variations of humidity, etc., depending on what is measured
and of the sensitivity of the device. It is often possible to reduce the noise by controlling the
environment.
In our project we are going to reduce the noise in the signal with the help of moving average filter. We
also calculate the signal to noise ratio in Matlab.
SNR:
Signal-to-noise ratio (SNR or S/N) is a measure used in science and engineering that compares the level
of a desired signal to the level of background noise. SNR is defined as the ratio of signal power to the
noise power, often expressed in decibels. A ratio higher than 1:1 (greater than 0 dB) indicates more
signal than noise.
• Additive because it is added to any noise that might be intrinsic to the information system.
• White refers to the idea that it has uniform power across the frequency band for the
information system. It is an analogy to the color white which has uniform emissions at all frequencies in
the visible spectrum.
• Gaussian because it has a normal distribution in the time domain with an average time domain
value of zero.
Implementation
In this project we will
➢ first take an audio signal and read that signal through audioread command in MATLAB and then
add the sufficient sample rate to play that audio at its original frequency.
➢ Then we add white gaussian noise to the original signal.
➢ Then we play the signal to check either voice is added or not.
➢ Then we measure the SNR(signal-to-noise ratio) of the noisy signal.
➢ Then we apply moving average filter on the noisy signal.
➢ Again we measure the SNR on the filtered signal.
➢ Then we play the signal to check either noise is reduced or not.
Source Code:
For 1st audio:
x=audioread('audio1.au');
x=x(1:116083,1);
%sound(x,50000);
subplot(3,4,1)
plot(x)
y =awgn(x,116083,3.0,'linear');
a=x+y;
%sound(a,50000)
subplot(3,4,2)
plot(a)
y=double(a(:));
ya=max(a(:));
yi=min(a(:));
ys=std(a(:));
snr=20*log10((ya-yi)./ys)
%atM=25 it gives correct result.
M = input('Desired length of the filter = ');
num =ones(1,M);
fil = filter(num,1,a)/M;
ap=double(fil(:));
aa=max(fil(:));
ai=min(fil(:));
as=std(fil(:));
snr1=20*log10((aa-ai)./as)
title('--Signal After filter--')
subplot(3,4,3)
plot(fil)
sound(fil,50000)
For 2nd audio:
x=audioread('audio2.au');
x=x(1:96347,1);
%sound(x,50000);
subplot(3,4,1)
plot(x)
y =awgn(x,96347,3.0,'linear');
a=x+y;
%sound(a,50000)
subplot(3,4,2)
plot(a)
y=double(a(:));
ya=max(a(:));
yi=min(a(:));
ys=std(a(:));
snr=20*log10((ya-yi)./ys)
%atM=25 it gives correct result.
M = input('Desired length of the filter = ');
num =ones(1,M);
fil = filter(num,1,a)/M;
ap=double(fil(:));
aa=max(fil(:));
ai=min(fil(:));
as=std(fil(:));
snr1=20*log10((aa-ai)./as)
title('--Signal After filter--')
subplot(3,4,3)
plot(fil)
%sound(fil,50000)
For 3rd audio:
x=audioread('audio3.au');
x=x(1:94387,1);
%sound(x,50000);
subplot(3,4,1)
plot(x)
y =awgn(x,94387,3.0,'linear');
a=x+y;
%sound(a,50000)
subplot(3,4,2)
plot(a)
y=double(a(:));
ya=max(a(:));
yi=min(a(:));
ys=std(a(:));
snr=20*log10((ya-yi)./ys)
%atM=25 it gives correct result.
M = input('Desired length of the filter = ');
num =ones(1,M);
fil = filter(num,1,a)/M;
ap=double(fil(:));
aa=max(fil(:));
ai=min(fil(:));
as=std(fil(:));
snr1=20*log10((aa-ai)./as);
display(snr1)
subplot(3,4,3)
plot(fil)
sound(fil,50000)
Discussion and analysis
During filtering of a noisy signal it has been observed that moving average filter will suppressed the
higher frequency to clear the noise in the signal.so if we want to suppress a higher frequency signal we
can use moving average filter.
Reference:
https://www.mathworks.com/help/matlab/ref/audioread.html
https://www.mathworks.com/help/signal/ref/snr.html
https://www.mathworks.com/help/comm/ref/awgn.html
https://www.mathworks.com/matlabcentral/answers/114442-how-to-design-a-moving-
average-filter
https://www.mathworks.com/help/matlab/import_export/record-and-play-audio.html