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

Are AudioBufferSourceNode.loopStart and .loopEnd subsample-accurate? #336

Closed
joeberkovitz opened this issue Jun 9, 2014 · 6 comments
Closed

Comments

@joeberkovitz
Copy link
Contributor

The spec should say whether the loop points specified for an AudioBuffer are subsample-accurate, or whether they are rounded to the nearest sample.

Most commercial sampler applications do not support subsample-accurate loop points and require loop points to be at exact sample frames, for efficiency's sake.

@cwilso
Copy link
Contributor

cwilso commented Oct 23, 2014

"No." :)

@mdjp
Copy link
Member

mdjp commented Oct 28, 2014

TPAC RESOLUTION: No.

@cwilso cwilso modified the milestone: Web Audio Last Call 1 Oct 29, 2014
@cwilso cwilso self-assigned this Oct 27, 2015
@rtoy
Copy link
Member

rtoy commented Jun 22, 2016

Curiously, the spec currently says loopStart and loopEnd are rounded to the nearest frame. I didn't look to see when this change was made.

However, I think Chrome does do subsample accurate loopStart and loopEnd. Here's an example

var context = new OfflineAudioContext(1, 100, 12800);
var src = context.createBufferSource();
var b = context.createBuffer(1, 3, context.sampleRate);
var d = b.getChannelData(0);
d[0] = 0;
d[1] = 1;
d[2] = 1;
src.buffer = b;
src.loop = true;
src.loopStart = 0.5 / context.sampleRate;
src.loopEnd = 2 / context.sampleRate;

src.connect(context.destination);
src.start();
context.startRendering().then (function (buffer) {
    console.log(buffer.getChannelData(0));
});

If there were no subsampling going on, the output should always be either 0 or 1. In Chrome, some samples are 0.5, indicating that subsampling is being done.

Presumably this is also true with Safari (webkit), Edge, and Opera too. I didn't test this though.

@padenot
Copy link
Member

padenot commented Jun 23, 2016

Gecko snaps to frames.

@joeberkovitz
Copy link
Contributor Author

This is a duplicate of #332, which itself was closed via #400. So, closing.

@hoch
Copy link
Member

hoch commented Nov 10, 2016

Note: the resolution is reverted by #915.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants