如何在MATLAB中使用fft从已录制的声音中消除噪声? [英] how can the noise be removed from a recorded sound,using fft in MATLAB?

查看:1161
本文介绍了如何在MATLAB中使用fft从已录制的声音中消除噪声?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从录制的声音中消除噪音,并让它先找到该声音的基本频率,但是我不知道如何消除这些噪音.我正在录制从不同高度掉落的物体的声音.我想找到声音的高度和最大频率之间的关系.

I want to remove noises from a recorded sound and make the fft of it finding fundamental frequencies of that sound, but I don't know how to remove those noises. I'm recording the sound of falling objects from different heights. I want to find the relation between the height and the maximum frequency of the recorded sound.

  [y,fs]=wavread('100cmfreefall.wav');

 ch1=y(:,1);
 time=(1/44100)*length(ch1);
t=linspace(0,time,length(ch1));


L=length(ch1);
 NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
Y1=log10(Y);
figure(1)

f = fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(Y1(1:NFFT/2+1))) ;

[b,a]=butter(10,3000/(44100/2),'high');
Y1=filtfilt(b,a,Y1);

% freqz(b,a)
figure(2)

plot(f,2*abs(Y1(1:NFFT/2+1))) ;

title('Single-Sided Amplitude Spectrum of y(t)');
xlabel('Frequency (Hz)');
ylabel('|Y(f)|')
xlim([0 50000])


% soundsc(ch1(1:100000),44100)

推荐答案

说信号中有噪声非常模糊,根本无法传达很多信息.一些问题是:

Saying that there is noise in your signal is very vague and doesn't convey much information at all. Some of the questions are:

  • 噪声是高频还是低频?
  • 它与信号的频带是否很好分开?或者混入了其中?
  • 噪声是否遵循统计模型?可以形容为固定过程吗?
  • 噪声是否是另一个确定性的干扰信号?

您采用的方法肯定取决于上述问题的答案.

The approach you take will certainly depend on the answers to the above questions.

但是,从您描述的实验设置来看,我的猜测是您的噪音只是背景噪音,在大多数情况下,自然界中可以近似为白色. 白噪声是指在所有频率下具有恒定功率的统计噪声模型.

However, from the experiment setup that you described, my guess is that your noise is just a background noise, that in most cases, can be approximated to be white in nature. White noise refers to a statistical noise model that has a constant power at all frequencies.

最简单的方法是使用低通滤波器或带通滤波器,仅保留您感兴趣的那些频率(如果您还不了解,则对频谱进行快速查看可以发现这一点).在我以前的答案中,有关使用MATLAB,我提供了创建低通滤波器和常见陷阱的示例.您可能可以通读一下,看看它是否对您有帮助.

The simplest approach will be to use a low pass filter or a band pass filter to retain only those frequencies that you are interested in (a quick look at the frequency spectrum should reveal this, if you do not know it already). In a previous answer of mine, to a related question on filtering using MATLAB, I provide examples of creating low-pass filters and common pitfalls. You can probably read through that and see if it helps you.

一个简单的示例:

考虑一个频率为50 Hz,以1000 Hz采样的正弦曲线.为此,我添加了高斯白噪声,以使SNR约为-6dB.原始信号和噪声信号可以在下图的第一行中看到(仅显示50个样本).如您所见,由于所有结构似乎都已被破坏,因此嘈杂的信号似乎几乎没有希望.但是,进行FFT可以显示出埋藏的正弦波(显示在底部)

Consider a sinusoid with a frequency of 50 Hz, sampled at 1000 Hz. To that, I add Gaussian white noise such that the SNR is ~ -6dB. The original signal and the noisy signal can be seen in the top row of the figure below (only 50 samples are shown). As you can see, it almost looks as if there is no hope with the noisy signal as all structure seems to have been destroyed. However, taking an FFT, reveals the buried sinusoid (shown in the bottom row)

使用48到52 Hz的窄带滤波器对噪声信号进行滤波,可以得到干净"的信号.由于噪声,振幅当然会有所损失.但是,信号最初是从看似丢失的原因中检索出来的.

Filtering the noisy signal with a narrow band filter from 48 to 52 Hz, gives us a "cleaned" signal. There will of course be some loss in amplitude due to the noise. However, the signal has been retrieved from what looked like a lost cause at first.

如何进行取决于您的确切应用.但是我希望这可以帮助您了解噪声过滤的一些基本知识.

How you proceed depends on your exact application. But I hope this helped you understand some of the basics of noise filtering.

编辑

@Shabnam:已经发表了将近50条评论,我真的没有看到您做出任何努力来理解,或者至少是自己尝试.您确实应该学习阅读文档并学习概念并尝试一下,而不是因每个错误而后退.无论如何,请尝试以下操作(从您的代码修改而来),​​并在注释中显示输出.

@Shabnam: It's been nearly 50 comments, and I really do not see you making any effort to understand or at the very least, try things on your own. You really should learn to read the documentation and learn the concepts and try it instead of running back for every single error. Anyway, please try the following (modified from your code) and show the output in the comments.

[y,fs]=wavread('100cmfreefall.wav');
ch1=y(:,1);
time=(1/fs)*length(ch1);
t=linspace(0,time,length(ch1));
L=length(ch1);
NFFT = 2^nextpow2(L);
f = fs/2*linspace(0,1,NFFT/2+1);

[b,a]=butter(10,3e3/(fs/2),'high'); 
y1=filtfilt(b,a,ch1);

figure(1)
subplot(2,1,1)
Y=fft(ch1,NFFT)/L;
plot(f,log10(abs(Y(1:NFFT/2+1))))
title('unfiltered')

subplot(2,1,2)
Y1=fft(y1,NFFT)/L;
plot(f,log10(abs(Y1(1:NFFT/2+1))))
title('filtered')

这篇关于如何在MATLAB中使用fft从已录制的声音中消除噪声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆