In what units does frequency fft return values?

dsp_module

#1

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.


#2

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.


#3

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)


#4

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…


#5

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


#6

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

Lovely, that makes sense now. Thanks!


#7

@daniel yes, exactly! :slight_smile: