Aquila DSP C++ Library - Wave file FFT analog frequency off by factor of 4? I'm working with the Aquila C++ DSP library. I'm computing the FFT of a wave file (16 bit depth, single channel, 44100 sample rate). I am using a window size of 16384 to calculate the FFT spectrum.

I'm having an issue converting the the digital frequency (0/N, 1/N, ... N/N) to the corresponding analog frequency. When I apply the sample rate multiplier S,

f = S*i/N; // Convert from digital frequency to analog frequency

I get analog frequencies that are 4 times greater than what I expect. 

For example, I read in a pianos A1 note. I expect this to be ~55 Hz. Instead I'm getting ~220 Hz. Refer to the photo below.



Now I'm first wondering if I'm scaling my the wrong number. However, I'm pretty sure it's correct. So now I'm curious if somehow the time domain data I'm reading is compressed by a factor of 4, such that the frequencies appear to be 4 times greater. Does anyone know if there is a common .wav file 'gotch-ya' when reading from them?

I've posted the relevant part of my code if anyone is interested.

/* sample window */
int window_size = 16384;

/* Calculate the FFT */
std::shared_ptr&lt;Aquila::Fft&gt; p_fft_interface = Aquila::FftFactory::getFft(window_size);  // This returns a shared pointer to an FFT calculation object.
auto spectrum = p_fft_interface-&gt;fft(wave_object.toArray());

QVector&lt;double&gt; x(window_size);
QVector&lt;double&gt; y(window_size);

/* Prepare to plot &amp; convert to analog frequency */
double max_value = 0;
for(int i = 0; i &lt; window_size; i++)
{
    x[i] = i*(sample_freq/window_size);
    y[i] = abs(spectrum[i]);

    if(abs(spectrum[i]) &gt; max_value)
    {
        max_value = abs(spectrum[i]);
    }
}
Not familiar with Aquila in particular, and I don't see how you're mapping the output spectrum samples to an X-axis that ends at 800 Hz,  but remember that a real-only FFT mirrors its output data in the second half of the buffer.  You may need to run your loop from 0 to window_size/2 if Aquila's FFT is implemented the usual way.  

That could account for a factor of 2x.