title: How to use inverse FFT on amplitude-frequency response?
body: <p>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.</p>
  
  <p>I have started with the following Matlab code:</p>
  
  <pre><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  
  </code></pre>
  
  <p>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>
  
  <pre><code>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)') 
  </code></pre>
  
  <p>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?</p>
  
  <p>Is there anything else I should know to get the FIR coefficients out of ifft?</p>