There are plenty threads on the forum, the magnifier icon lets you search for FFT to find e.g. this thread:
It has been a while since I used an FFT and instead of porting some old C# sharp code I’m trying out juce’s.
Here’s what I understand:
The frequency of bin[x] = Fs / nth Record.
In the past I have multiplied the real and imageinary parts but using fft::performFrequencyOnlyForwardTransform only modifies the array going in. Is the data in that array a linear amplitude?
My other question is if say the FFT is (10th Order) 512 bins do I need to supply 512 or 1024 samples? (my guess is that if its…
TL;DR: the amplitude is linear from 0 to fft.getSize(), so you might want to normalise by:
y = jmap (bin [i], 0.0f, float (fft.getSize()), float (bounds.getBottom()), float (bounds.getY()));
Now the frequency is linear as well (which is annoying, since you get plenty information about higher frequencies, but not much for lower ones).
These are the two mapping functions I use:
inline float indexToX (float index, float minFreq) const
const auto freq = (sampleRate * index) / fft.getSize();
return (freq > 0.01f) ? std::log (freq / minFreq) / std::log (2.0f) : 0.0f;
inline float binToY (float bin, const Rectangle<float> bounds) const
const float infinity = -80.0f;
return jmap (Decibels::gainToDecibels (bin, infinity),
infinity, 0.0f, bounds.getBottom(), bounds.getY());
Hope that helps