AudioThumbnail::drawChannel performance issue

I wonder what’s the CPU effecient way of using AudioThumbnail::drawChannel.

In my app I need to visualize many waveforms onscreen. I use AudioThumbnail::drawChannel, and only draw the visible area. It’s working okay. However, when there are many thumbnails loaded, and I change the visible area by scrolling the viewport horizontally, it’s very heavy on the CPU. I profiled the app and 97% is used in AudioThumbnail::drawChannel while scrolling the view. The refillCache call inside drawChannel is really heavy, and it’s triggered whenever I ask the thumbnail to draw a different part of the waveform. Even if that part was already drawn before (so it doesn’t look like thumbnail tries to cache the whole waveform). the screenshot of the profiling is below. Is there a more effective way to use AudioThumbnail::drawChannel?

This is how I use the thumbnail:

thumbnail->drawChannel (g,

Screenshot 2022-04-29 at 19.21.06