Skip to content
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

Add currentFrame to AudioWorkletGlobalScope #1491

Closed
rtoy opened this issue Feb 9, 2018 · 1 comment
Closed

Add currentFrame to AudioWorkletGlobalScope #1491

rtoy opened this issue Feb 9, 2018 · 1 comment
Milestone

Comments

@rtoy
Copy link
Member

rtoy commented Feb 9, 2018

The AudioWorkletGlobalScope has currentTime to let the processor know the current time. It would also be very nice to have currentFrame that is the frame counter where currentTime = currentFrame/sampleRate.

For algorithms that need precise timing and complex computations wrt to time, using frames reduces round-off errors.

In Chrome, currentTime used to be accumulated each render quantum, causing a small round-off each time. This slight drift was noticeable after even a short time. Switching Chrome's internal implementation to count frames got rid a huge class of round-off errors.

Doing the same in Chrome's AudioParam implementation greatly reduced the small, but subtle issues in timing. Before fixing this, @hoch had an example where his synthesizer would suddenly stop producing output because of round-off in the audio param implementation. Changing the implementation to work with frames instead of time fixed this and a bunch of other issues.

@padenot
Copy link
Member

padenot commented Feb 13, 2018

Agreed. Gecko does everything in frames internally, exactly for this reason.

@mdjp mdjp added this to the Web Audio V1 milestone Feb 15, 2018
@rtoy rtoy added this to To Do in V1 Feb 27, 2018
@rtoy rtoy closed this as completed in 9f33982 Apr 12, 2018
rtoy added a commit that referenced this issue Apr 12, 2018
Fix #1491: Add currentFrame to worklet global scope
V1 automation moved this from To Do to Done Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants