I’m working on a small program that generates animations and, for most parts, it’s working as expected. The only place where I’m facing a problem is when the midi onset’s are of incredibly small duration and my animation then goes extremely out of sync.
A basic outline of my process is this:
Find the difference between the current onset and the onset that follows it (in seconds).
Generate n frames for the current onset where n is round(difference * frame rate)
But when too many small duration onset’s are played together, the entire animation that follows it goes out of sync because all the minimal time lags caused rounding n in step 2 sum up.
Is there a better way to tackle this problem where my animation would be in sync regardless of the changes in onset’s?
In step 1, the difference is computed based on unrounded times. But you have to use the actual time when the current onset becomes visible. This is the sum of all previous n, divided by the frame rate.