Confused about output of the JUCE forward fft

Hi,
I’m a bit confused about the output of the juce forward fft (performRealOnlyForwardTransform).
I created a buffer with exactly one period of a sinewave, amplitude 1.
After doing the FFT I get a value in the second bin. Which is correct. When using an FFT size of 1024, I expect a value of 1024 in the real part of that bin (I used a cosine). But the value is 512.
So I have to scale it by 1/(N/2). I always read that that you need to scale by 1/N.
So what is wrong here?

The 1024-element FFT gives you 1024 frequency bins, from 0 Hz to the sampling rate. But we can only use frequencies up to Nyquist, which is at half the sample rate. The bins between Nyquist and the sample rate are mirrored copies of the bins 0 - Nyquist.

This means there isn’t just one bin that registers your cosine wave, but two bins (bin 1 and bin 1023 in this case). Since the energy for the cosine is divided over two bins, each only has half the magnitude.

Ah, so that explains it. Thx.
BTW, it doesn’t matter if you do a real or complex fft? You allways get these mirrored part?

Look at the declaration of this method from the documentation, particularly the last argument.

void performRealOnlyForwardTransform (float *inputOutputData, bool onlyCalculateNonNegativeFrequencies=false) const noexcept

:+1: