Neutone / neutone_sdk

Join the community on Discord for more discussions around Neutone! https://discord.gg/VHSMzb8Wqp
GNU Lesser General Public License v2.1
470 stars 22 forks source link

[cm] Saturation and minimum delay calculation improvements and tests #9

Closed christhetree closed 1 year ago

christhetree commented 1 year ago

The previous saturation and delay calculations were written for a more general case and therefore became too complicated. They were also incorrect for certain specific edge cases. Now that we know that the incoming buffer size is mostly fixed unless the DAW changes, I've simplified the calculations (and added a much more complicated one that is actually correct) and added tests to ensure they are correct for all combinations.

I've also tweaked the behavior of the is_queue_saturated flag to enable the model to start processing earlier rather than waiting for the queue to be saturated. This should help prevent extra processing delay from heavy models (but doesn't eliminate it of course) in certain conditions.

The logic behind the saturation calculation is kind of messy and I think it would be best to write a blog about this with some nice diagrams. I think it's more worth it to look at the tests.