Re: [whatwg] Gapless playback problems with web audio standards

On Tue, Oct 28, 2014 at 1:13 AM, David Kendal <me@dpk.io> wrote:

> On 27 Oct 2014, at 12:08, Robert O'Callahan <robert@ocallahan.org> wrote:
>
> > Web Audio should be usable for this. If it doesn't work due to brower
> bugs, we should fix the browser bugs. I know we've fixed bugs related to
> this in Firefox this year so I'd like to know if obvious techniques still
> don't work.
>
> Can you suggest an ‘obvious technique’ I don’t describe in my email? Given
> that none of the techniques there work even remotely directly with samples,
> but rather with approximate durations, I don’t see how it’s possible to get
> sample-accurate transitions.
>

Durations are floating point, and browsers should round them to the nearest
sample boundary, so there shouldn't be a problem there.

If you have a set of AudioBuffers that you want to play gaplessly, you
should just be able to do this:
var audioBuffers = ...;
var audioContext = new AudioContext();
var t = 0;
for (var i = 0; i < audioBuffers.length; ++i) {
  var node = audioContext.createBufferSource();
  node.buffer = audioBuffers[i];
  node.start(t);
  t += buffer.duration;
}

For best results the audioBuffers' sample rate should match the sample rate
of audioContext, though I think Firefox should work even when that's not
the case.

Rob
-- 
oIo otoeololo oyooouo otohoaoto oaonoyooonoeo owohooo oioso oaonogoroyo
owoiotoho oao oboroootohoeoro oooro osoiosotoeoro owoiololo oboeo
osouobojoeocoto otooo ojouodogomoeonoto.o oAogoaoiono,o oaonoyooonoeo
owohooo
osoaoyoso otooo oao oboroootohoeoro oooro osoiosotoeoro,o o‘oRoaocoao,o’o
oioso
oaonosowoeoroaoboloeo otooo otohoeo ocooouoroto.o oAonodo oaonoyooonoeo
owohooo
osoaoyoso,o o‘oYooouo ofooooolo!o’o owoiololo oboeo oiono odoaonogoeoro
ooofo
otohoeo ofoioroeo ooofo ohoeololo.

Received on Tuesday, 28 October 2014 03:51:08 UTC