我正在尝试创建一个应用程序来计算图形均衡器 FIR 滤波器的系数。我在 Matlab 中做一些原型设计,但我遇到了一些问题。
我从以下 Matlab 代码开始:
% 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 数据的结尾丢失了:
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)')
所以我想,我用错了。我是否需要将我的 binamps 向量加倍并在第二部分创建一个镜像?如果是这种情况,那么仅仅是 Matlab 的 ifft 实现还是其他 C/C++ FFT 库(尤其是 Ooura FFT)需要镜像数据来进行逆 FFT?
还有什么我应该知道的以从 ifft 中获取 FIR 系数吗?