You’re very unlikely to find a magic library that does exactly what you want, so juce’s AudioThumbnail class is probably as good a starting point as anything else out there!
Here’s the magic library! Jokes aside, I recently did exactly that for streamed waveforms. The basic idea is to split up the signal in phase-aligned bands (Linkwitz-Riley crossovers, for instance) whose energy corresponds to a colour. When you paint the waveform, you accumulate the colour for each band at each sample, and normalize the colour.
It depends on what you want to do… But for mapping spectral energy and density to colours, it works extremely well and gives per-sample results that are easily interpolatable and smoothable:
The FFT approach would be better if you want to colour the highest magnitude frequency in the window, or something…
I did some multicolored waveform drawing using 3 bandpass filters (for low, mid, high bands), and use the values of the 3 bands as basis for the RGB values when drawing the waveform.
Looks like this:
I actually used the so called ‘Superpowered sdk’, which has functions to analyze an audio file, and spit out three different bandpass filtered waveforms. Those are essentially my RGB values.
I just looked at the DrowAudio link mentioned above, which basically does the same.