[英]How to use inverse FFT on amplitude-frequency response?
我正在嘗試創建一個計算圖形均衡器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)')
所以我想,我正在使用ifft錯誤。 我需要讓我的binamp矢量兩倍長,並在它的第二部分創建一個鏡子嗎? 如果是這種情況,那么它只是Matlab實現的ifft或其他C / C ++ FFT庫(尤其是Ooura FFT)需要用於逆FFT的鏡像數據嗎?
還有什么我應該知道從ifft獲得FIR系數嗎?
為了得到真實的結果,任何典型的通用IFFT(不僅僅是Matlab的實現)的輸入都需要是復共軛對稱的。 因此,使用給定數量的獨立規格點進行IFFT將需要至少兩倍的FFT(優選甚至更長以允許從最高頻率截止轉變為零)。
試圖通過丟棄復雜結果的“虛構”部分來獲得真實結果將不起作用,因為您將丟棄實時所需的信息內容,時域濾波器需要輸入到IFFT的給定頻率響應。 但是,如果原始數據是共軛對稱的,那么IFFT / FFT結果的虛部將是(通常無關緊要的)可以丟棄的舍入誤差噪聲。
此外,有限頻率響應的DTFT將產生無限長的FIR。 要獲得有限長度的FIR,您需要妥協您的頻率響應規范的規范,以便在時域表示的后一部分中留下很少的能量,必須從FIR截斷以使其可實現或有限。 一種常見(但不是必要的最佳)方法是窗口IFFT產生的FIR結果,並通過反復試驗嘗試不同的窗口,直到找到FFT產生結果的FIR濾波器“足夠接近你的原始頻率規格。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.