如何在幅度-频率响应上使用逆FFT? [英] How to use inverse FFT on amplitude-frequency response?

查看:216
本文介绍了如何在幅度-频率响应上使用逆FFT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个用于计算图形均衡器FIR滤波器的系数的应用程序.我正在Matlab中做一些原型设计,但是有一些问题.

I am trying to create an application for calculating coefficients for a graphic equalizer FIR filter. I am doing some prototyping in Matlab but I have some problems.

我已经开始使用以下Matlab代码:

I have started with the following Matlab code:

    % binamps vector holds 2^13 = 8192 bins of desired amplitude values for frequencies in range 0.001 .. 22050 Hz (half of samplerate 44100 Hz)
    % it looks just fine, when I use Matlab plot() function 
    % now I get ifft
    n = size(binamps,1);
    iff = ifft(binamps, n);
    coeffs = real(iff); % throw away the imaginary part, because FIR module will not use it anyway  

但是当我执行系数的fft()时,我看到频率被拉伸了2倍,并且我的AFR数据的结尾丢失了:

But when I do the fft() of the coefficients, I see that the frequencies are stretched 2 times and the ending of my AFR data is lost:

p = fft(coeffs, n); % take the fourier transform of coefficients for a test

nUniquePts = ceil((n+1)/2); 
p = p(1:nUniquePts); % select just the first half since the second half 
                       % is a mirror image of the first
p = abs(p); % take the absolute value, or the magnitude 
p = p/n; % scale by the number of points so that
           % the magnitude does not depend on the length 
           % of the signal or on its sampling frequency  
p = p.^2;  % square it to get the power 

sampFreq = 44100;
freqArray = (0:nUniquePts-1) * (sampFreq / n); % create the frequency array 
semilogx(freqArray, 10*log10(p)) 
axis([10, 30000 -Inf Inf])
xlabel('Frequency (Hz)') 
ylabel('Power (dB)') 

所以我想我在使用ifft时出错.我是否需要使双安培向量的长度加倍,并在其第二部分创建一个镜像?如果是这种情况,那么是否仅仅是Matlab的ifft实现或其他C/C ++ FFT库(尤其是Ooura FFT)需要镜像数据进行逆FFT?

So I guess, I am using ifft wrong. Do I need to make my binamps vector twice as long and create a mirror in the second part of it? If it is the case, then is it just a Matlab's implementation of ifft or also other C/C++ FFT libraries (especially Ooura FFT) need mirrored data for inverse FFT?

我还有什么要知道从ifft中获取FIR系数的信息吗?

Is there anything else I should know to get the FIR coefficients out of ifft?

推荐答案

您的频域向量必须是复杂的,而不仅仅是真实的,并且它必须关于中点对称以获取纯实时域信号.将实部设置为所需的幅度值,并将虚部设置为零.实部必须具有均匀的对称性,以使A[N - i] = A[i](A[0]A[N / 2]是特殊"的,它们是DC和Nyquist分量-只需将它们设置为零即可.)

Your frequency domain vector needs to be complex rather than just real, and it needs to be symmetric about the mid point in order to get a purely real time domain signal. Set the real parts to your desired magnitude values and set the imaginary parts to zero. The real parts need to have even symmetry such that A[N - i] = A[i] (A[0] and A[N / 2] are "special", being the DC and Nyquist components - just set these to zero.)

以上内容适用于任何通用的复数到复数FFT/IFFT,而不仅仅是MATLAB的实现.

The above applies to any general purpose complex-to-complex FFT/IFFT, not just MATLAB's implementation.

请注意,如果您要设计具有任意频率响应的时域滤波器,则需要先在频域中进行一些加窗处理.您可能会发现本文很有帮助-它讨论了使用MATLAB的任意FIR滤波器设计,尤其是 fir2 .

Note that if you're trying to design a time domain filter with an arbitrary frequency response then you'll need to do some windowing in the frequency domain first. You might find this article helpful - it talks about arbitrary FIR filter design usign MATLAB, in particular fir2.

这篇关于如何在幅度-频率响应上使用逆FFT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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