-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
start(currentTime + baseLatency) behavior isn't strictly defined #2467
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The linked message is not correct.
The spec accurately says what should happen, not why nor how, it's not a user-manual. Sometimes we add non-normative notes, but not here. In this particular case, it's clear what happens when Firefox's behaviour was implemented a while back and hasn't been updated since this was specced. It lags behind the spec, so this is a Firefox bug, that I intend to fix.
The downside to the way the spec says things should be done is that there is no guarantee that:
results in two oscillators starting in phase. It's well possible that the two start calls happen in different render quantums (same if/when passing an explicit start time, see the column Description of the spec). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thanks for clarifying! So if I'm understanding correctly:
So that only leaves currentTime. The definition seems to describe Chrome's behavior of an always up-to-date value. So it sounds like we're all set then. Nothing to see here. 🙂 If the solution to #2410 ends up being another latency value that gets added to currentTime, I suppose that would help keep multiple oscillators in phase as well. Will be interesting to see how that plays out. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Closing per #2467 (comment). |
Describe the issue
Browser differences with
baseLatency
,currentTime
,start
, andstop
prevent sounds from being scheduled precisely.#2397 (comment) suggests that
start(currentTime + baseLatency)
should reliably play a sound at the indicated time, but that's not true in all browsers. If it were, playing a click sound effect would be easy:This works in Chrome but not in Firefox. There are a few relevant bug reports (956574, 966585, 1228207, 1248731), but they've been open for nearly a decade, and it's unclear if they're even considered spec violations or just optional enhancements.
I consider this a spec bug because everyone seems to have a different idea of what these values are for, making it tougher to develop a reliable app. The spec describes what the fields are without clarifying what they're useful for. (Especially baseLatency.)
If we agree that
start(currentTime + baseLatency)
should be predictable under normal circumstances, then explicit language or examples could be added to the spec. This may also make issues like #2410 less visible. I considered adding a more focused comment under that issue, as the "more global scheduling latency value" mentioned in #2410 (comment) sounds like it would help. But it wouldn't actually help without tightening up the existing fields first. And once that's done, baseLatency might already serve that purpose.Where Is It
https://webaudio.github.io/web-audio-api/#dom-baseaudiocontext-currenttime
https://webaudio.github.io/web-audio-api/#dom-audiocontext-baselatency
https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-start
https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-stop
Additional Information
baseLatency
currentTime
start(currentTime + baseLatency)
stop(currentTime + baseLatency + 0.002)
currentTime + baseLatency + 0.002
is already in the past.Adding a constant delay (at least 20ms) helps, but isn't reliable since the actual delay depends on how long the current task has taken, how much more time it will take, and even how many other tasks are queued. The only reliable fix is to prerender sound effects using an OfflineAudioContext, then use AudioBufferSourceNode (whose start method accepts a duration) instead of OscillatorNode.
Is there a downside to Chrome's behavior? Does the structure of Firefox (or other implementations) make it particularly difficult to standardize this behavior?
The text was updated successfully, but these errors were encountered: