Tonejs / Tone.js

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

Inaccurate timing using triggerAttackRelease #952

Closed jeremyfromearth closed 2 years ago

jeremyfromearth commented 2 years ago

Firstly, I've spent the last couple of weeks working with Tone and I think that the design of the library is really elegant and well thought out. Thanks for all of your work thus far.

Describe the bug Triggering notes, using triggerAttackRelease, from the tick callback of a Tone.Sequence on instruments such as MonoSynth, Sampler and others seems to be slightly intermittently delayed, causing very noticeable inaccuracies in timing. I do not see this behavior when I use Tone.Players from within the same callback. The timing is quite good in that case.

To Reproduce I'm including a simple isolated demonstration that can be run from the examples folder. You can uncomment lines in the callback to compare Sampler and Players accuracy. You can also test them at the same time and hear the discrepancy in their playback of the same sample. sampler-vs-players.zip

Expected behavior For all notes triggered in the tick callback to be accurately timed, like a metronome.

What I've tried

Additional context Hardware: 2016 MacBook Pro, 2.9 GHz Quad-Core Intel Core i7 OS: MacOS Big Sur Same behavior can be heard on modern versions of Chrome, Safari and Firefox.

tambien commented 2 years ago

Maybe the same issue as #918

Make sure you pass the value that Tone.Sequence gives you through to triggerAttackRelease.

jeremyfromearth commented 2 years ago

@tambien Thank you for the quick reply. This was exactly the problem. Back on track now!