matlab - 消除mp3文件中的噪音,MATLAB

标签 matlab audio noise-reduction

我在下面的链接中有一个mp3文件,其中背景是人的声音和嗡嗡声。我要消除嗡嗡声。有谁可以告诉我如何在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;

我希望可以消除嗡嗡声,但是输出声音像原始声音一样。

enter link description here

最佳答案

我已经下载了您在问题中链接的原始文件,并在末尾添加了以下行:

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

生成的文件“filtered.wav”听起来与我的耳朵非常不同(我使用头戴式耳机收听)。例如,如果您在Audacity中打开“filtered.wav”并查看频谱,则它的确与原始频谱有所不同(如预期的那样,将删除700 Hz以下和12 kHz以上的频率)。

让我们尝试在matlab中对此进行验证。以下脚本读取两个文件并绘制两个fft的dB值。下方的图表示滤波后的信号,可以清楚地看到低音频率已被消除。超过12 kHz的切口也是可见的,但似乎这些频率已在原始信号中衰减,而带通滤波器对此进行了增强。
%% 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)

关于matlab - 消除mp3文件中的噪音,MATLAB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53991975/

相关文章:

c - Matlab卷积代码在C中

matlab - 生成特定持续时间内频率的斜坡音频信号

algorithm - 多 channel 格递归最小二乘法

java - 检测图像中的物体(单词)

matlab - 在 MATLAB 中查找矩阵子集的最大值,同时保留完整矩阵的索引

java - java.sql.DriverManager.getConnection 突然出现 "license checkout failed"

winforms - 声音播放程序

c# - 如何在 C# 中播放 MP3 流

c++ - OpenCV - 去除图像中的噪声

matlab - 是否可以使用 DSP System Toolbox(MATLAB) 实时处理两个麦克风输入?