Я пытаюсь создать приложение для расчета коэффициентов для КИХ-фильтра графического эквалайзера.Я делаю некоторые прототипы в 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 вдвое длиннее и создать зеркало во второй его части?Если это так, то является ли реализация Matlab ifft или другим библиотекам C / C ++ FFT (особенно Ooura FFT) нуждающимися в зеркальных данных для обратного FFT?
Есть ли что-то еще, что я должен знать, чтобы получитькоэффициенты РПИ из ifft?