In what units does frequency fft return values?



Subj. Talking about performFrequencyOnlyForwardTransform function. It doesnt seem to be 0-1, alot of values are way above 1. I want to get it in dBs if possible.


As shown in the SimpleFFTExample project from the JUCE example folder, you can map the output values of the FFT by using the jmap function and the FloatVectorOperations::findMinAndMax() function beforehand to find the minimum and maximum values in your output values.

To convert from a gain value to a decibel value, use the Decibels::gainToDecibels() function and specify the value you want for -INF dB.


Except it wouldnt be correct, since the values always gonna be normalized, and changing the volume of the incoming sound wouldnt affect the spectrum analyzer output. Anyway, ive done it already, more or less acceptably correct, just by using log(2 * level / fftSize)


That seems like a good starting point. Can somebody with good elementary maths skills comment on that, if that is the right approach, or is it just approximating?

When I start to add a serious analyser to my projects, I would want it to be based on proper maths rather than guesswork…


The output from preformFrequencyOnlyForwardFFT() is in the range 0 to the size of the FFT.


And this is then gain values, so I transform them to dB using the Decibels::gainToDecibels, right?

Lovely, that makes sense now. Thanks!


@daniel yes, exactly! :slight_smile: