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

Web Audio is unsuitable for music tracks due to needing to download and
fully decompress in to memory the entire track before starting playback. It
would be nice if this could "just work" with the HTML5 audio loop tag.

Ashley


On 28 October 2014 18:06, Dale Curtis <dalecurtis@chromium.org> wrote:

> Yes, both WebAudio and MSE can do that, though I'd probably lean towards
> WebAudio for anything game related. Using WebAudio just create a buffer
> source and set the loop attribute:
>
> https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode.loop
>
> The way you could do it with MediaSource would be to "double buffer" the
> track such that you're creating an infinite stream. I.e. append a new copy
> of the track as time reaches the end of the previously appended track. To
> avoid unnecessary memory usage you would remove stale copies of the data
> once played.
>
> - dale
>
> On Tue, Oct 28, 2014 at 9:55 AM, Ashley Gullen <ashley@scirra.com> wrote:
>
>> Can this be used for gapless looping of the same track? This is a common
>> request for game developers looking to seamlessly loop a music or ambience
>> track: https://code.google.com/p/chromium/issues/detail?id=353072
>>
>> Ashley
>>
>>
>> On 27 October 2014 20:09, Dale Curtis <dalecurtis@chromium.org> wrote:
>>
>>> Hi,
>>>
>>> Chrome developer here, gapless playback should work with both WebAudio
>>> and
>>> Media Source Extensions (MSE). I've fixed bugs in both implementations,
>>> so
>>> if you have some test cases in Chrome that fail, I'd love to see them. As
>>> luck has it, I've recently put an article together on how to use MSE for
>>> gapless playback:
>>>
>>> http://dalecurtis.github.io/llama-demo/index.html
>>>
>>> We'll be posting it to HTML5Rocks in the near future. Feel free to
>>> contact
>>> me if you have any questions. You also note that setTimeout() is not
>>> precise enough for your usage; you should take a look at the WebAudio
>>> scheduler or using WebWorkers:
>>>
>>> http://www.html5rocks.com/en/tutorials/audio/scheduling/
>>> https://github.com/chrisguttandin/worker-timers
>>>
>>> If you only need your project to work in the foreground using
>>> requestAnimationFrame is also an option. I'd first try to schedule as
>>> much
>>> as you can in advance though.
>>>
>>> - dale
>>>
>>
>>
>

Received on Tuesday, 28 October 2014 18:59:39 UTC