グラフィックイコライザー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を間違って使用していると思います。binampsベクトルを2倍の長さにし、その2番目の部分にミラーを作成する必要がありますか?その場合、Matlabのifftの実装だけですか、それとも他のC / C ++ FFTライブラリ(特にOoura FFT)が逆FFTのミラーリングされたデータを必要としますか?
FIR係数をifftから取得するために知っておくべきことは他にありますか?