how FFT output is encoded in the single variable 'value' ?

The Audacity file TrackArtist.cpp contains a method TrackArtist::DrawClipSpectrum(…) which is responsible for the FFT conversion of a waveform and the drawing on screen of the Spectrum of that waveform. The amplitudes of the different frequencies in the spectrum are displayed on screen by different colors.

In that DrawClipSpectrum() method there is a single float called ‘value’ which contains the information with which a single frequency in the spectrum at one particular point in time can be displayed, thus:

  • the frequency which is detected by the FFT routine

and

  • the signal strength of that detected frequency.

The method

  • GetColorGradient(value, selflag, mIsGrayscale, &rv, &gv, &bv);

converts the encoded info of ‘value’ into the three basic color values rv, gv and bv which together make the color by which the amplitude of a particular frequency is indicated.

My problem is that I can’t deduce from the source code how a single freqency and its amplitude are both encoded in this single float ‘value’.
The source code is poorly commented on that issue.

Is there anybody who can explain me the encoding rules of this float ‘value’ ?
or do I have to contact the author Dominic Mazzoni himselve in the hope he still remembers?

Thanks for any help,
jerome42

I doubt that the frequency is encoded in this variable - only the Amplitude (or Magnitude).
The frequency is always known, it is just the bin index multiplied by the fixed bin distance.
It is possible that 2 Bytes make up the index but a float is rather short for that, isn’t it?
I don’t know much about C++ and I haven’t studied the source code, sorry if that’s all wrong.

I think you are very right. Indeed, the frequency isn’t encoded in ‘value’, a possibility that never occurred to me, but after some experimenting, that must be the right conclusion. As you say, ‘value’ gives only the amplitude of the frequency and is normalized into a range between 0.0 and 1.0. A float can handle that very well. So keep away from C++ and from diving into the source code: apparently that gives the best insight!
Thank you Robert, for your very logic perspective.