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

2014-10-28 Thread Dale Curtis
Unfortunately, making loop in the bare audio tag sample accurate in Chrome
is non-trivial for a variety of reasons, so it's unlikely to happen anytime
soon. The MSE based approach should work great in the meantime; I've used
the approach described above for seamless audio+video looping.

- dale

On Tue, Oct 28, 2014 at 11:59 AM, Ashley Gullen  wrote:

> 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  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  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  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

>>>
>>>
>>
>


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

2014-10-28 Thread Ashley Gullen
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  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  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  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
>>>
>>
>>
>


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

2014-10-28 Thread Dale Curtis
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  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  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
>>
>
>


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

2014-10-28 Thread Ashley Gullen
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  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
>


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

2014-10-27 Thread Robert O'Callahan
On Tue, Oct 28, 2014 at 1:13 AM, David Kendal  wrote:

> On 27 Oct 2014, at 12:08, Robert O'Callahan  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 ofolo!o’o owoiololo oboeo oiono odoaonogoeoro
ooofo
otohoeo ofoioroeo ooofo ohoeololo.


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

2014-10-27 Thread Dale Curtis
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


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

2014-10-27 Thread David Kendal
On 27 Oct 2014, at 12:08, Robert O'Callahan  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.

Silvia Pfeiffer suggested using Media Source Extensions, which looks more 
promising, but I don’t see how they can be used to ‘join’ the samples from two 
different audio files into the same buffer.

> Rob

dpk



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

2014-10-27 Thread Robert O'Callahan
On Sun, Oct 26, 2014 at 2:30 AM, David Kendal  wrote:

> Hi,
>
> 
>

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.

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 ofolo!o’o owoiololo oboeo oiono odoaonogoeoro
ooofo
otohoeo ofoioroeo ooofo ohoeololo.


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

2014-10-25 Thread Kevin Marks
To get gapless, you need to be sample accurate, which is sub millisecond
precision. A playlist element had been discussed before - making it the
browser's job to be sample accurate.

The quicktime plugin had a working version of this a decade ago; SMIL was
supposed to be the way to do it, but a declarative media playlist seems a
natural thing to absorb into the browser as an 80:20 case, rather than the
cross media sync that SMIL promised and didn't deliver.
On 25 Oct 2014 06:30, "David Kendal"  wrote:

> Hi,
>
> 
>
> dpk
>
>


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

2014-10-25 Thread Silvia Pfeiffer
Have you tried media source extensions?

Best Regards,
Silvia.
On 26 Oct 2014 00:30, "David Kendal"  wrote:

> Hi,
>
> 
>
> dpk
>
>