Closed natepmay closed 2 years ago
Hi @natepmay. The code you provided looks fine to me and running similar code for me does not produce that issue.
AudioContext.currentTime is native to the Web Audio API so might not be a Tone.js issue. If it's happening on iOS only sounds like it might be specific to that platform. Is it possible that there are maybe too many things running on the page and the browser is running out of processing resources?
If it's possible to reproduce the issue then i can try to look further into it
@tambien thanks so much for taking a look and testing it out. I feel better hearing you say there's nothing weird in the code itself. I'll keep trying to catch the problem red-handed and seeing if browser resources may be the issue. I'll also be interested to see if anyone else finds this thread and reports a similar problem. Since the problem seems to be with the Web Audio API feel free to close out the issue.
My web app makes an FMSynth named
synth
globally, then defines a sequence globally like this:(The function
makeMidiArray
just chooses octaves for pitches and turns them into Tone.Midi events and doesn't seem to be the problem).The user plays single notes using
triggerAttackRelease()
with the transport stopped, as well as playing sequences using this function:Occasionally, users have reported that the app freezes up, and when I finally was able to reproduce the error and debug I noticed that the
currentTime
of the AudioContext had stopped incrementing at 63.328. RunningTone.start()
in the console returned a promise that was "resolved" instead of "fulfilled" as it is when the app is working.The error seems to be mostly or only happening on iOs but it's really hard to tell because it's so inconsistent. Any idea why the time stops incrementing?
Note: I'm noticing now that I should call Tone.now() twice—once for stopping and then again for starting. Could that be what's freezing up the whole app?