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

Clarification on AudioBufferSourceNode looping, and loop points #2072

Closed
padenot opened this issue Oct 3, 2019 · 1 comment
Closed

Clarification on AudioBufferSourceNode looping, and loop points #2072

padenot opened this issue Oct 3, 2019 · 1 comment
Assignees
Milestone

Comments

@padenot
Copy link
Member

padenot commented Oct 3, 2019

The spec is weird (emphasis mine):

The offset parameter supplies a playhead position where playback will begin. If 0 is passed in for this value, then playback will start from the beginning of the buffer. A RangeError exception MUST be thrown if offset is negative. If offset is greater than loopEnd, playback will begin at loopEnd (and immediately loop to loopStart). offset is silently clamped to [0, duration], when startTime is reached, where duration is the value of the duration attribute of the AudioBuffer set to the buffer attribute of this AudioBufferSourceNode.

There are a number of issues and questions here, all answered by the algorithm:

  • This is true only when playbackRate is > 0. If no, then it will go backward in the loop. The normative algorithm says yes, only when looping is enabled. This could be fixed by changing the prose.
  • Does this need to happen only when looping is enabled? The algorithm, which is normative says says yes. This is fine, but we need to change the prose.
  • Does the opposite happen when playbackRate is < 0, meaning the offset should be clamped in [loopStart, loopEnd] ? The normative algorithm says no. This seems inconsistent, but is the current normative requirement.
  • In this case, is it allowed to start after the looped region, and then enter the looped region like it is for the positive playbackRate case? The normative algorithm says no. his seems inconsistent, but is the current normative requirement.

Examples:

Normal case

With a buffer of 3.0 seconds: starting, say, at 0.0, with a playbackRate of 1.0, and end/start loop points of respectively 1.0 and 2.0, will play [0.0, 1.0], then looping continuously in [1.0, 2.0].

Backward case

With a buffer of 3.0 second: starting, say, at 3.0, with a playbackRate of -1.0, and end/start loop points of respectively 1.0 and 2.0, will play [2.0, 3.0] backwards, then looping continuously (also backwards) in [1.0, 2.0].

@padenot
Copy link
Member Author

padenot commented Oct 10, 2019

Call resolution:

  • At least fix the first two bullet point, by considering the algorithm is right, and adjusting the prose
  • Have a look to see if fixing the two other points is easy. It probably is. There is an implementation in webkit iirc.

@mdjp mdjp added this to the Web Audio V1 milestone Oct 10, 2019
padenot added a commit to padenot/web-audio-api that referenced this issue Oct 29, 2019
…rameter of the AudioBufferSourceNode start method

This fixes WebAudio#2072, WebAudio#2031.
padenot added a commit to padenot/web-audio-api that referenced this issue Oct 29, 2019
…rameter of the AudioBufferSourceNode start method

This fixes the first part of WebAudio#2072.
@padenot padenot self-assigned this Oct 29, 2019
padenot added a commit that referenced this issue Nov 14, 2019
…rameter of the AudioBufferSourceNode start method

This fixes the first part of #2072.
@padenot padenot closed this as completed Nov 14, 2019
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

2 participants