Tonejs / Tone.js

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

Trivial Tone.Player example plays unstable volume #999

Closed jtwigg closed 2 years ago

jtwigg commented 2 years ago

Describe the bug

I'm finding Tone.js to will play a one shot sample with a double volume on Chrome on its 2nd or third time in the loop. It doesn't appear to be impacting Safari. It seems particularly sensitive to the certain BPM of 125 (crazy I know)

https://codepen.io/jtwigg/pen/jOGMGaJ?editors=1111

To Reproduce

https://codepen.io/jtwigg/pen/jOGMGaJ?editors=1111

1) Use Chrome on a Mac. In particular I'm using a new M1 2) In the example, you need to wait just a little for the JS to load, but when it does a) Click the Play 125BPM and listen for it to loop a few times. About the 2nd or 3rd time it plays it will play twice as loud. b) Restart/refresh the page to restart the test c) Try the 125.1 BPM and it play stably.

Expected behavior The volume shouldn't be extra loud.

What I've tried Different BPM's have different don't cause the issue. I've tried loops, longer Transport loop points.

Additional context Definitely Chrome related as Safari is not producing the issue.

I'm pulling out my hair here. I can't even do the most trivial or trivial things right now. I really need this to work...

dirkk0 commented 2 years ago

might be related to #944

jtwigg commented 2 years ago

@dirkk0 Thanks for replying. I'll keep an eye on this issue, but I'm now looking at talking to Web Audio API directly to see if I can achieve what I need. I was really hoping to use the Tone.js scheduling etc which was powerfull.

tambien commented 2 years ago

Thanks for the test case!

Seems like this double scheduling was due to a floating point error. Just pushed a change which should fix that, will be deployed in the tone@next once it passes through CI