You are on page 1of 7

REMOVING ENGINE NOISE

FROM A NOISY SIGNAL


ECE 301-01 Final Project Report
Brandon Adduci, Ben Bachmann
Bradley University ECE Department
Introduction
The goal of this project is to remove the engine noise from a noisy signal in an effort to hear the
song being played as clearly as possible. This is done through a series of filters that allow for much
of the original song to be retained all the while removing the engine noise from the provided noisy
audio signal.

Design Method and Specifications


In order to properly remove engine noise from the signal, many options for filter design were
available including: a series of band-stop/high-pass filters, a statistical approach using correlation,
and various Simulink alternatives to MATLAB. In choosing the most optimal method, the
understanding of the MATLAB filters being used and the perceived effectiveness of the various
filters were taken into account.

The following specifications (Figure 2) were chosen after careful consideration and analysis of the
provided reference noise and song signal spectrums (seen later in Figure 5.1). It could be shown
through our analysis that there was minimal data from the song within these frequencies, allowing
for maximum retention of the original signal.

Name Frequency
𝐹𝑠 44100 Hz
𝑓𝑐 (High-pass) 95 Hz

𝑓𝐿1 , 𝑓𝐻1 (Band-stop) 270, 377 Hz

𝑓𝐿2, 𝑓𝐻2 (Band-stop) 403, 480 Hz

𝑓𝐿3 , 𝑓𝐻3 (Band-stop) 830, 1680 Hz

Figure 2. Filter Specifications


Figure 1. Identifying Period of Noisy Signal

Engineering Effort
Design Procedures
The following procedure was followed to achieve the desired results:
1. Analyze the frequency spectrums of both the noisy and unnoisy signals
2. Identify areas with large amounts of noise/corruption
3. Remove any found noise while maintaining as much of the original signal as possible
In analyzing the frequency spectrums, the areas of specified in Figure 1 were found to have the
larges amount of noise when compared with the reference noisy signal. In an effort to remove these
areas of interest, the following filters were created in MATLAB using the parameters described
above:

1
% Filtering
ROI_data_d = highpass(ROI_data,95,Fs);
ROI_data_d = bandstop(ROI_data_d,[270 377],Fs);
ROI_data_d = bandstop(ROI_data_d,[403 480],Fs);
ROI_data_d = bandstop(ROI_data_d,[830 1680],Fs);

Figure 3. MATLAB Filter Code

Results
The resultant reduction in noise was measured by taking the power
of the measured data subtracted by the power of the song signal to Signal Noise Ratio
find the power of the original noise signal, as well as the power of
Original 7.546 dB
the denoised signal subtracted by the song signal to find the power
of the remaining noise. Using the respective noise ratios, it can be Denoised 19.793 dB
found that the signal to noise ratio increased by 2.616 times, or there
Figure 4. Signal to Noise Ratios
was 162.3% less noise after the filters.

Figure 5.1. Frequency Domain Analysis Figure 5.2. Highlighting Denoised Portion Figure 5.3. Comparison of Signals

Figure 5.1 displays the Fast Fourier Transform (FFT) of the measured data in addition to the noisy
data. This is used to determine which frequencies should be filtered out. Once the noisy data is
passed through our denoising algorithm, the resulting FFT can be seen in the lower plot of Figure
5.1. Effects of the four applied filters are shown with low amplitude valleys in the frequency data.
Then, it is converted to time domain using an Inverse Fast Fourier Transform, or IFFT. Figure 5.2
shows the denoised portion inserted into the non-corrupted data, having a lower overall amplitude
in comparison with the original noisy portion. This amplitude decrease can be seen more clearly in
Figure 5.3, where the denoised data is overlayed on top of the noisy data.

2
Discussion
In beginning analysis of the two provided signals, the original strategy was to remove frequencies
below a certain threshold, as had been done in the past for pervious exercises. For this particular
circumstance, however, this strategy proved fruitless, as the engine noise did not remain within any
given frequency threshold for the duration of the signal but rather changed along with the song. If
the engine noise did not remain consistent, then an alternative methodology would be required.
The first alternative method attempted was to line up the noisy signal with the provided noisy
engine signal, and then subtract the engine noise from the noisy signal. This alternative method
seemingly had no change on the apparent noisy-ness of the signal. The attempt was followed by the
final method which would use multiple filters, a high-pass, and a series of band-stop filters as
described above. This method proved to be the most effective of the methods attempted, and, with
some adjustment of the filter parameters, sufficient noise was removed.

Conclusion
While the entirety of the noise cannot be removed from the provided signal, a sufficient amount of
that noise was able to be reduced, allowing for clearer song to be heard. While other methods for
achieving this level of reduction were possible, the chosen method was found to be effective for this
use case, resulting in a reduction of 162.3%.

Appendix
%% ECE 301 Project 3
% Brandon Adduci and Benjamen Bachmann

clc;
close all;
clear all;

%Print header
header;

%% User Parameters

% MOVE PLOTS? y/n


a = 'y';

% PLAY DENOISED AUDIO? y/n


b = 'n';

%% Initial Data Manipulation

%Load Engine Noise


load ECE301_Project3_engine_data.mat;

%Load Data
ROI_data = corrupted_data1(220501:1764000);
ROI_song = song_ref(220501:1764000);
ROI_noise = noise_ref;

%Plot Original Data


figure(1);
3
time = 1:length(corrupted_data1);
time = time/Fs;

plot(time,corrupted_data1,'Color',[0, 0.8, 0.1]); ylim([-2 2]);


%Plot Original Data
figure(1);

time = 1:length(corrupted_data1);
time = time/Fs;

plot(time,corrupted_data1,'Color',[0, 0.8, 0.1]); ylim([-2 2]);


xlabel('Time (s)'); ylabel('Amplitude'); title('Measured Song Data with
Corrupted Portion');

hold on;

ROI_plot = nan(length(corrupted_data1),1);
ROI_plot(220501:1764000) = corrupted_data1(220501:1764000);
plot(time,ROI_plot,'r-');
legend('Measured Data','Highlighted Noisy Portion');

%% Perform Denoising

% FFT of Original Song for Comparison


song_FFT = fft(ROI_song,Fs);
song_FFT = song_FFT/(max(abs(song_FFT)));

% FFT of Measured Data


data_FFT = fft(ROI_data, Fs);
data_FFT = data_FFT/(max(abs(data_FFT)));

figure(2);
subplot(2,1,1);
plot(abs(data_FFT),'r-','LineWidth',1.1);xlim([0 3000]);

% FFT of Reference Noise


noise_FFT = fft(ROI_noise, Fs);
noise_FFT = noise_FFT/(max(abs(noise_FFT)));

hold on;

plot(abs(noise_FFT),'-.','Color',[1, 0.5, 0.1]);


title("Noisy Data and Reference Noise Spectrum");
xlabel('Frequency (Hz)'); ylabel('Normalized Amplitude');
legend('Noisy Data Spectrum','Reference Noise Spectrum');

% Filtering
ROI_data_d = highpass(ROI_data,95,Fs);
ROI_data_d = bandstop(ROI_data_d,[270 377],Fs);
ROI_data_d = bandstop(ROI_data_d,[403 480],Fs);
ROI_data_d = bandstop(ROI_data_d,[830 1680],Fs);

% Plot Denoised Signal


figure(3);

corrupted_data1(220501:1764000) = nan;
plot(time,corrupted_data1,'Color',[0, 0.8, 0.1]); ylim([-2 2]);
xlabel('Time (s)'); ylabel('Amplitude');4 title('Denoised Data with Corrupted
Portion');

hold on;
corrupted_data1(220501:1764000) = nan;
plot(time,corrupted_data1,'Color',[0, 0.8, 0.1]); ylim([-2 2]);
xlabel('Time (s)'); ylabel('Amplitude'); title('Denoised Data with Corrupted
Portion');

hold on;

ROI_plot = nan(length(corrupted_data1),1);
ROI_plot(220501:1764000) = ROI_data_d;
plot(time,ROI_plot,'b');
legend('Measured Data','Highlighted Denoised Portion');

% Plot Denoised and Original Signal For Comparison


figure(4);
ROI_time = time(220501:1764000);
plot(ROI_time,ROI_data,'r-');
hold on;
plot(ROI_time,ROI_data_d,'b-');
ylim([-1.5 1.5]);
title('Comparison of Noisy and Denoised Signals');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Noisy Data','Denoised Data');

% FFT of Denoised Signal


denoised_FFT = fft(ROI_data_d,Fs);
denoised_FFT = denoised_FFT/(max(abs(denoised_FFT)));

figure(2);
subplot(2,1,2);
plot(abs(denoised_FFT),'b-');xlim([0 3000]);
title('Denoised Spectrum');
xlabel('Frequency (Hz)'); ylabel('Normalized Amplitude');

% Measure Effectiveness with Power of Noise in Signal (S/N ratio)


p_data = sum(abs(data_FFT).^2);
p_denoised = sum(abs(denoised_FFT).^2);
p_song = sum(abs(song_FFT).^2);
p_noise = sum(abs(noise_FFT).^2);

p_noise_original = p_data-p_song;
p_noise_remaining = p_denoised-p_song;

SN_original = p_data/p_noise_original; %Signal to Noise Ratio of Original


Data
SN_denoised = p_denoised/p_noise_remaining; %Signal to Noise Ratio of Denoised

SN_original_dB = 20*log10(SN_original); %Convert S/N to dB


SN_denoised_dB = 20*log10(SN_denoised);

fprintf("\t Signal To Noise Ratios:\n");


fprintf("\t\tOriginal: %f dB\n", SN_original_dB);
fprintf("\t\tDenoised: %f dB\n", SN_denoised_dB);

fprintf("\n\nNote: The signal to noise ratios provide an objective way of


measuring the removal of noise from the 5signal.\n");

%call concluding functions


moveplots(a);
fprintf("\n\nNote: The signal to noise ratios provide an objective way of
measuring the removal of noise from the signal.\n");

%call concluding functions


moveplots(a);
playsound(b,ROI_data_d,Fs);

%% Functions
function header()
fprintf("\t\tECE301 Project 3\n")
fprintf("\t\tEngine Denoising\n")
fprintf(" Brandon Adduci and Ben Bachmann \n")
fprintf("------------------------------------\n\n")
end

%Move plots if desired


function moveplots(a)
if(a=='y')
movegui(1,"northwest");
movegui(2,"north");
movegui(3,"northeast");
movegui(4,"south");
end

end

%Play final sound if desired


function playsound(b,ROI_data,Fs)
if(b=='y')
% player = audioplayer(ROI_data,Fs);
% play(player);
soundsc(ROI_data,Fs);
end
end

Appendix A. MATLAB Code

You might also like