2

I have a mp3 file in the link below, where there is a man human voice and some humming noise in the background. I want the humming noise removed. Is there anyone who can tell me how to do it in MATLAB? https://www.dropbox.com/s/h95y1oelbzvcgkc/allthatbass.mp3?dl=0

%% Read in the file
clearvars;
close all;
[f,fs] = audioread('allthatbass.mp3');
%% Play original file
pOrig = audioplayer(f,fs);
N = size(f,1);
%% Plot the spectrum
df = fs / N;
w = (-(N/2):(N/2)-1)*df;
y = fft(f(:,1), N) / N; % For normalizing, but not needed for our analysis
y2 = fftshift(y);
figure;
plot(w,abs(y2));
%% Design a bandpass filter that filters out between 700 to 12000 Hz
n = 7;
beginFreq = 700 / (fs/2);
endFreq = 12000 / (fs/2);
[b,a] = butter(n, [beginFreq, endFreq], 'bandpass');
%% Filter the signal
fOut = filter(b, a, f);
%% Construct audioplayer object and play
p = audioplayer(fOut, fs);
p.play;

I expect the humming noise removed, but the output sound like the original sound.

enter link description here

beaker
  • 16,331
  • 3
  • 32
  • 49

2 Answers2

1

I have downloaded the original file you linked in your question and added the following line at the end:

audiowrite('filtered.wav', fOut, fs);

The resulting file 'filtered.wav' sounds very different to my ears (I used a headset to listen). If you open 'filtered.wav' for example in Audacity and take a look at the spectrum then it looks indeed different from the original (as expected, the frequencies below 700 Hz and above 12 kHz are removed).

Let's try to verify this in matlab. The following script reads both files and plots the dB value of both ffts. The lower plot represents the filtered signal and it is clearly visible that the bass frequencies are removed. The cut above 12 kHz is visible as well but it seems that these frequencies have already been attenuated in the original signal and the bandpass filter reinforces that.

%% Read in both files
clearvars;
close all;
[f,fs] = audioread('allthatbass.mp3');
[fflt, fsflt] = audioread('filtered.wav');
N = size(f,1);
%% Compute the ffts
df = fs / N;
n = N / 2; % plot only the second half of the spectrum
w = (0:(n)-1)*df;
y = fft(f(:,1), N) / N;
y2 = fftshift(y);
yflt = fft(fflt(:,1), N) / N;
y2flt = fftshift(yflt);
%% Plot the spectrum of both files (use the dB value, i.e. 10 * log(abs(x)) )
figure;
ax1 = subplot(2,1,1);
plot(w,10*log(abs(y2(n:end-1,1))));
ax2 = subplot(2,1,2);
plot(w, 10*log(abs(y2flt(n:end-1,1))));
linkaxes([ax1, ax2], 'y'); % link the axes (this makes it easier to visually compare the plots)
Marius
  • 1,529
  • 6
  • 21
0

Try using a low pass filter in MATLAB. They're relatively easy to implement. You can find the documentation, along with examples, here.

Lambda1010
  • 369
  • 2
  • 3
  • 13