如何使用快速基于FFT的卷积来实现低通滤波器,如果快速卷积需要一个低通滤波器? [英] How can I use fast FFT-based convolution to implement a LPF if the fast convolution requires a LPF?

查看:448
本文介绍了如何使用快速基于FFT的卷积来实现低通滤波器,如果快速卷积需要一个低通滤波器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名经验丰富的软件工程师,一些小的高校DSP知识。我正在一个智能电话应用程序来处理信号数据,如从麦克风(采样44100赫兹)和加速度计(采样32-50赫兹)。我的应用将是,例如,音调检测器等等。

I'm an experienced software engineer with some minor college DSP knowledge. I'm working on a smartphone application to process signal data, such as from the microphone (sampled at 44100 Hz) and the accelerometer (sampled at 32-50 Hz). My applications would be, for example, pitch detectors and so forth.

我想要实现手机上的一个低通滤波器(LPF)以去除混淆频率,特别是用于加速度计,其具有低采样速率。 但是,我发现一个矛盾,试图运用快速的基于FFT的卷积时的方法。任何帮助将是AP preciated。

I want to implement a low-pass filter (LPF) on the phone to remove aliased frequencies, particularly for the accelerometer, which has a low sampling rate. However, I am finding a contradiction when trying to apply the fast FFT-based convolution method. Any help would be appreciated.

下面是我的推理:

  1. 我读的信号,我想用一个低通滤波器做抗锯齿(删除混淆频率)。

  1. I am reading a signal, and I want use a LPF to do anti-aliasing (remove aliased frequencies).

要实现LPF我的智能手机,我选择适用的FIR滤波器(即一个窗口正弦函数)的时域信号。令x [n]的是我的信号和F [N]是我的过滤器内核的系数。所以我想执行X [n]和F [N],其中x [n]是长度为N(通常为512)和F [N]之间卷积的长度为M(通常为256)。

To implement the LPF on my smartphone, I choose to apply an FIR filter (namely, a windowed sinc function) to the time-domain signal. Let x[n] be my signal and f[n] be the coefficients of my filter kernel. So I want to perform convolution between x[n] and f[n], where x[n] is of length N (typically 512) and f[n] is of length M (typically 256).

我实现了我的智能手机(Android和iPhone)一个简单的一维卷积。该算法是典型的循环嵌套版本并运行在O(NM)。它在智能手机上运行过慢N = 512和M = 256。

I implemented a simple 1D convolution on my smartphone (Android and iPhone). The algorithm is the typical nested loop version and runs in O(N M). It is running too slowly on the smartphone for N=512 and M=256.

然后我看着快速卷积算法。具体地,经滤波的信号是从:滤波x [n]的= IFFT(FFT(x)的* FFT(六)。),其中的FFT是FFT,IFFT是逆FFT,并且*是元件逐元素相乘。两个数组。

I then looked at the fast convolution algorithm that uses FFTs and runs in O(N lgN). Specifically, the filtered signal is from: filtered x[n] = IFFT(FFT(x) .* FFT(f)), where FFT is the fft, IFFT is the inverse FFT, and .* is element-by-element multiplication of two arrays.

不过,我觉得在这个过程中一个矛盾:IFFT( FFT(X) * FFT(F))。这就要求我拍X [N]的FFT,但X [N]可能有混淆频率。这也正是我从第1步最初的问题!

However, I find a contradiction in that process: IFFT(FFT(x) .* FFT(f)). This requires that I take the FFT of x[n], but x[n] may have aliased frequencies. This is exactly my initial problem from step 1!

那么,我该怎么解决这个矛盾?如何使用快速卷积来实现低通滤波器,如果快速卷积内部需要一个低通滤波器?

So, how can I resolve this contradiction? How can I use fast convolution to implement a LPF if the fast convolution internally requires a LPF?

注:我已经告诉一些EE家伙有些麦克风具有基于硬件的LPF内置的,但我不能肯定我的智能手机的麦克风或加速度计

NOTE: I've been told by some EE guys that some microphones have a hardware-based LPF built in, but I cannot be sure with my smartphone's microphone or the accelerometer.

推荐答案

简单地:计算FFT(x)的不引入混叠

To put it simply: calculating FFT(x) does not introduce aliasing.

混叠引入每次信号进行采样的时间。我想你的困惑的根源在于有两个采样过程的音频信号:一次在你要添加的下采样步采取连续的声音,使之成为44.1kHz的信号,然后再次

Aliasing is introduced every time a signal is sampled. I think the root of your confusion is that there are two sampling processes for the audio signal: once to take continuous sound and make it a 44.1 kHz signal, and then again in the downsampling step you want to add.

说有在30千赫(比如)一个虚假的语气:它必须由智能手机的硬件被拒绝。一旦你拥有了这些44.1kHz的采样,你坚持什么别名产品通过采样得到的。您不能撤消取样后走样(这并不完全正确,但它是真实的基带信号,这是你正在处理什么用)。你应该继续前进,假设手机设计师得到这个权利,你就不必从信号内容的担心别名产品高出〜20 kHz的。

Say there was a spurious tone at 30 kHz (for instance): it must be rejected by the smartphone's hardware. Once you have those 44.1 kHz samples, you're stuck with whatever alias products got through the sampler. You cannot undo aliasing after sampling (this is not strictly true, but it's true for baseband signals, which is what you are dealing with). You should go ahead and assume that the phone designers got this right, and you won't have to worry about alias products from signal content higher than ~20 kHz.

这给我们带来了第二个采样步骤。你说的很对,你需要你降低采样率之前应用另一种抗混叠滤波器。 20 kHz以下,但高于2倍的下采样率将别名到输出,除非你先削弱它的任何信号内容。关键是,你计算FFT(x)的前下采样,然后应用过滤器,然后下采样。这是什么让你获得别名保护的输出。

Which brings us to the second sampling step. You are quite correct that you need to apply another anti-alias filter before you downsample. Any signal content below 20 kHz but above 2x your downsampled rate will alias into the output unless you attenuate it first. The key is that you are calculating FFT(x) BEFORE downsampling, then applying the filter, then downsampling. This is what allows you to get alias-protected outputs.

最有可能的智能手机有一个Δ-ΣADC,它采用了相对醇厚模拟抗混叠滤波器,1或2极,然后以极高的速率采样(64 * 44.1 kHz或更高)然后应用数字滤波器在其下采样过程。 MEMS加速度计同样具有内在的抗混叠保护。如果你想测试,使用迷上了一个电动摇床(或结实的低音炮锥)正弦波源和动摇你的电话几kHz。您应该看到在加速度计信号无输出。然后驱动高音单元为30千赫,看看话筒显示任何东西。

Most likely the smartphone has a delta-sigma ADC, which uses a relatively mellow analog anti-alias filter, either 1 or 2 pole, then samples at an extremely high rate (64 * 44.1 kHz or higher) then applies digital filters in its downsampling process. MEMS accelerometers similarly have intrinsic anti-alias protection. If you want to test this, use a sine wave source hooked up to an electrodynamic shaker (or a beefy subwoofer cone) and shake your phone at a few kHz. You should see no output on the accelerometer signal. Then drive a tweeter at 30 kHz and see if the mic shows anything.

这篇关于如何使用快速基于FFT的卷积来实现低通滤波器,如果快速卷积需要一个低通滤波器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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