Cancelling the background Noise by subtraction in frequency domain

13 visualizaciones (últimos 30 días)
Hi
these are the Audio Files that I am working on.
S1= the background Noise (Noise of drilling machine) , and S2= the background Noise + The targeted sound. Both of S1&S2 have the same length and same sampling F. Please listen to it.
I want to cancel the background noise in order to get only the targeted sound. In the Code below I plot both signals in time and frequency domain, after that I subtracted the fft(S2)- fft(S1) . I expected that should give me the targeted sound but i ended up having the same sound in S2.
My question is as follows:
1- Is this the best way to cancel the noise ?
2- Or should I use a frequency filter ? if yes what filter should I use ?
the Code :
close all; clear all; clc;
%%Analyse the audio
[y, Fs] = audioread('S1.mp3');
% Plot the Time Domain Representation
t = (0:1/Fs:(length(y)-1)/Fs);
subplot(2,2,1)
plot(t,y)
title('Time Domain - Background Noise')
xlabel('Time (seconds)')
ylabel('Amplitude')
xlim([0 t(end)])
% Plot the Frequency Domain Representation
m = length(y);
x = fft(y, m);
f = (0:m-1)*(Fs/m);
amplitude = abs(x)/m;
subplot(2,2,2)
plot(f(1:(m/2)),amplitude(1:(m/2)))
title('Frequency Domain - Background Noise')
xlabel('Frequency')
ylabel('Amplitude')
xlim([0 20000])
%%Analyse the noise audio
[y_n, Fs_n] = audioread('S2.mp3');
% Plot the Time Domain Representation
t_n = (0:1/Fs_n:(length(y_n)-1)/Fs_n);
subplot(2,2,3)
plot(t_n,y_n)
title('Time Domain - Background Noise + Targeted Sound ')
xlabel('Time (seconds)')
ylabel('Amplitude')
xlim([0 t(end)])
% Plot the Frequency Domain Representation
a = length(y_n);
v = fft(y_n, a);
f_n = (0:a-1)*(Fs/a);
amplitude = abs(v)/a;
subplot(2,2,4)
plot(f_n(1:(a/2)),amplitude(1:(a/2)))
title('Frequency Domain - Background Noise + Targeted Sound ')
xlabel('Frequency')
ylabel('Amplitude')
xlim([0 20000])
%ylim([0 0.02])
%%SUBTRACTION IN Frequency domain
% Plot the Frequency Domain Representation
a = length(y);
v = fft(y_n, a)-fft(y, a);
f_n = (0:a-1)*(Fs/a);
amplitude = abs(v)/a;
figure;
plot(f_n(1:(a/2)),amplitude(1:(a/2)))
title('Frequency Domain - Targeted Sound ')
xlabel('Frequency')
ylabel('Amplitude')
xlim([0 20000])
S=real(ifft(v));
sound(S);
  2 comentarios
Carlos Alva
Carlos Alva el 7 de Sept. de 2019
Editada: Carlos Alva el 7 de Sept. de 2019
Frequency subtraction works well however it is critical that the input samples line up, that is
S1 = Audio + S2
S2 = noise
Only in this condition you will see the benefit. The effort in this type of process is to insert and adjust delay lines (registers) to ensure the alignment before the summing junction, otherwise the spectrum of the noise will be added out of phase to the spectrum of the signal effectively putting it back in.
Image Analyst
Image Analyst el 8 de Sept. de 2019
Have you tried the wiener filter function?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by