Tone.js: Transport + Players. Events go out of sync after 25-50 repetitions.
I’m layering 4 bar loops at 126.25bps (ogg with 6 decimal places of timing accuracy) at 320kbps so fairly light. After 25-50 iterations timing goes out of sync and eventually eliminates as much as a quarter note out of the loop. Inlcuding performance summary from Chrome representing structure of a single Task. I’m using React and not sure how you tested this (with loops) so might be a good opportunity to take a look as setup is in CodeSandbox. I’m attaching player in Track.jsx and using player object loop like this for every track.
https://codesandbox.io/s/github/MusicAsCode/set-player/tree/master/
player.autostart = false;
player.loop = true;
player.loopStart = "0:0:0";
player.loopEnd = "4:0:0";
player.toMaster().sync();
player.start();
This is quite a big Task structure that takes over 20ms to execute (this is from a still correctly audible iteration) Are they normally as complex or am I doing something wrong. Any recommendations?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 16 (4 by maintainers)
@styk-tv If this issue is still persisting it might be because you are setting state from within the Loop callback. I had a similar issue that I resolved by removing any state updates from within the callback. In React state updates are not instant so in this case they are causing issues.
Also if you use Tone.Sequence instead you can keep track of the current step by using the second argument.
I am working to port this to 14+ …
@tambien Yotam,
tested with 3.8.34 and issue still remains. interesting fact is that this incremental start offset (issue) being added on every loop restart persists Tone.Stop() and Tone.Start()
All digging points to conclusion that player settings are honoured:
transport setup
but transport settings especially start position is slowly shifting forwards, so it manifests with empty space then proper loop start, then loop cut off at the end repeat. in case of my example it takes 32 iterations to be audible. with tempo at 60/126.25bpm and loop at 4 bars = 7.603960396039604 per loop and audible at 243+ seconds
attaching paste of the transport beat positions. standard 4/4 signature 4 bars so 16 beats per iteration. you can see that scheduler seems to be doing a good job for a while, but after average above the error is so big that it jumps into the next quarter note and completely looses a beat.
this ubuntu pastebin is valid for a year until 2021-03-08, it represents 4 tracks (for same size loops) being played over and over, each one independently reporting its playback beat position.
https://paste.ubuntu.com/p/SywzwNmzwn/
Progressively Shifting Transport Start 0:0:0 Position:
transport compensation lost the battle it seems