W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2014

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

From: Robert O'Callahan <robert@ocallahan.org>
Date: Tue, 28 Oct 2014 16:50:40 +1300
Message-ID: <CAOp6jLaBOP-K1PK_gXqQDz9LAzzOH+AkYiVZN2C7DKZ4J6RL5w@mail.gmail.com>
To: David Kendal <me@dpk.io>
Cc: whatwg <whatwg@lists.whatwg.org>
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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:24 UTC