Juce different coloured waveform based on play position


I am trying to set the waveform to have a different colour before and after (my code below), but at the moment the waveform isn’t remaining static once its drawn.

Am I over complicating this?

Does anyone have any feedback?

I’m not sure if I understand correctly what you mean. Perhaps you need 2 instances of the Audiothumbnail?

I have cloned AudioThumbnail and added a bit of code. I now have what I called “MulticolorAudiothumbnail” which allows you to draw sections of the waveform in a different color.

I know it’s not ideal to copy an existing class as all changes made to the original would also need to be copied to your clone but I didn’t find a better way at the time and the solution works. My use case was to draw a waveform in a selected state eg with inverted colors.

Let me know if you want me to share it.

Yes, I would be very curious to see how you did it?

OOoh please share this, I am also in need of this.
Thank you!

1 Like

I don’t think you need to alter the code. What you can do is draw the whole waveform in one colour and then reduce the clip area and draw the selection with a different colour on top.
That results in the selection being drawn twice. But the AudioThumbnail is clever enough to only draw the not clipped area (the loop for adding the rectangles respects the clipRect).

Very insightful Daniel! Thank you