Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.39k stars 976 forks source link

Transport Position Runs Beyond Loop End #1110

Open abswiz opened 2 years ago

abswiz commented 2 years ago

Describe the bug

Tone JS v14.8.40 Upon certain scenarios, which appear to be related to bpm and transport settings, the running transport position can go beyond the set loop end position.

To Reproduce

https://codepen.io/abswiz/pen/vYRqGKm?editors=1111

Expected behavior

Running Transport position should not go beyond the loop end time. The consequences are inadvertent triggering of scheduled items beyond the end of the loop.

What I've tried

Codepen supplied earlier, but we have tried different interactive tests (dappledark.com/composer) to set different bpms and bar positions. Certain bpm and bar (measure) combinations appear to reveal the problem more often. One example is in the codepen, but we have experienced others. This appears to be related to the tick calculations used for the loop calcs and those of the transport position. One of the calcs floors the result whereas the other one doesn't. For now, we have included additional checks to avoid processing items beyond the loopEnd, but this adds additional performance overhead as well as the need to refactor and regression test.

Additional context