Tracktion / tracktion_engine

Tracktion Engine module
Other
1.16k stars 148 forks source link

Thumbnail cache is invalid if time range is short #114

Open JordanSkousen opened 2 years ago

JordanSkousen commented 2 years ago

Hi all,

I've discovered an issue with the TracktionThumbnail::CachedWindow::refillCache function.

From my understanding, if the thumbnail time range is shorter than the CachedWindow has cached, then it begins reading audio level data "on the fly" from the source. This check between using the cache and going "on the fly" is performed here.

When the cache is refilled "on the fly" - the time range is too short for the cache to be used - then it returns invalid data. For some reason, the first several levels are 0. When small adjustments are made to the start of the time range, the thumbnail doesn't always change as expected - the beginning appears to stay in place and the whole thing stretches. I made a test application to demonstrate this. Here's a screen recording of it:

https://user-images.githubusercontent.com/35109863/157196868-2a808e7c-c424-484a-a6ee-cb8d87515bba.mp4

You can download the source files for this test app here: test_tracktion_waveform_bug.zip