Can you help remove the noise from this audio file?

73 visualizzazioni (ultimi 30 giorni)
I'm having trouble removing the noise heard from this audio file audio_sample.wav.
I've attempted to use the "butter" function to experiment with removing certain frequencies in an effort to reduce the noise as much as possible.
You will need to have the audio file in the search path your MATLAB is using.
The code will play my "current solution".
Thanks for any help.
%%1) Load the 'audio_sample.wav' file in MATLAB
[sample_data, sample_rate] = audioread('audio_sample.wav');
% a. Plot the signal in time and the amplitude of its frequency
% components using the FFT.
sample_period = 1/sample_rate;
t = (0:sample_period:(length(sample_data)-1)/sample_rate);
subplot(2,2,1)
plot(t,sample_data)
title('Time Domain Representation - Unfiltered Sound')
xlabel('Time (seconds)')
ylabel('Amplitude')
xlim([0 t(end)])
m = length(sample_data); % Original sample length.
n = pow2(nextpow2(m)); % Transforming the length so that the number of
% samples is a power of 2. This can make the transform computation
% significantly faster,particularly for sample sizes with large prime
% factors.
y = fft(sample_data, n);
f = (0:n-1)*(sample_rate/n);
amplitude = abs(y)/n;
subplot(2,2,2)
plot(f(1:floor(n/2)),amplitude(1:floor(n/2)))
title('Frequency Domain Representation - Unfiltered Sound')
xlabel('Frequency')
ylabel('Amplitude')
% b. Listen to the audio file.
% sound(sample_data, sample_rate)
%%2) Filter the audio sample data to remove noise from the signal.
order = 7;
[b,a] = butter(order,1000/(sample_rate/2),'low');
filtered_sound = filter(b,a,sample_data);
sound(filtered_sound, sample_rate)
t1 = (0:sample_period:(length(filtered_sound)-1)/sample_rate);
subplot(2,2,3)
plot(t1,filtered_sound)
title('Time Domain Representation - Filtered Sound')
xlabel('Time (seconds)')
ylabel('Amplitude')
xlim([0 t1(end)])
m1 = length(sample_data); % Original sample length.
n1 = pow2(nextpow2(m1)); % Transforming the length so that the number of
% samples is a power of 2. This can make the transform computation
% significantly faster,particularly for sample sizes with large prime
% factors.
y1 = fft(filtered_sound, n1);
f = (0:n1-1)*(sample_rate/n1);
amplitude = abs(y1)/n1;
subplot(2,2,4)
plot(f(1:floor(n1/2)),amplitude(1:floor(n1/2)))
title('Frequency Domain Representation - Filtered Sound')
xlabel('Frequency')
ylabel('Amplitude')
  2 Commenti
Allen Bastian
Allen Bastian il 14 Mag 2020
can u help to remove instrumental part to give just the audio?
shenghua cha
shenghua cha il 3 Apr 2021
I am doing an experiment recently. Your code and files may be helpful to me. Could you please send them to me?

Accedi per commentare.

Risposta accettata

Star Strider
Star Strider il 18 Set 2017
It is not possible to eliminate broadband noise with a frequency-selective filter. You have to use wavelets to effectively de-noise it.
I got reasonable results with this filter, and using the filtfilt function:
Fs = sample_rate; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = 1000/Fn; % Passband Frequency (Normalised)
Ws = 1010/Fn; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple (dB)
Rs = 150; % Stopband Ripple (dB)
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs); % Filter Order
[z,p,k] = cheby2(n,Rs,Ws,'low'); % Filter Design
[soslp,glp] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(3)
freqz(soslp, 2^16, Fs) % Filter Bode Plot
filtered_sound = filtfilt(soslp, glp, sample_data);
sound(filtered_sound, sample_rate)
Experiment to get the results you want.
  11 Commenti
Andrew Selley
Andrew Selley il 22 Apr 2022
Hi can you show the code on how you implemented this in order to remove the noise? I know i'm a little late to the party here.
Star Strider
Star Strider il 22 Apr 2022
Andrew Selley —
I did in my original Answer. (I would now use an elliptic filter. The code is essentially the same, switching to the elliptic filter functions.) Frequency-selective filters are onoly useful for band-limited noise, and that can be determined by using the fft function. Christopher Vergara’s initial Comment nicely describes that entire process.
For broadband noise, use the Savitzky-Golay filter (sgolayfilt) function. I usually use a degree 3 polynomial and vary the other parameters to get the result I want. Another option is wavelet denoising, however that requires the Wavelet Toolbox.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by