Re: replay AudioBufferSourceNode ?

On Tue, Mar 20, 2012 at 12:29 AM, Jerome Etienne
<jerome.etienne@gmail.com>wrote:

> Hello
>
> As i understand AudioBufferSourceNode Interface[1], it isn't possible
> to play several time a bufferSource (correct me if im wrong).
>

Yes, this is true.


> Nevertheless in a game, a sound is played many-many times. So
> BufferSource javascript object needs to be recreated, fully
> reconfigured and reconnect every time you play it. This is rather
> cumbersome for the developer. How can i clone an existing BufferSource
> ? maybe somebody did a javascript function on top of the spec ?
>

Although it may seem strange at first, I think it's straight-forward and
works quite well.  There are a few tutorials/blogs explaining how this
works, for example:

Please see the playSound() function here:
http://www.html5rocks.com/en/tutorials/webaudio/intro/

It's only a few lines of JavaScript which is wrapped up in a function which
is simple to call each time a particular sound needs to be played.



>
> Jerome
>
> [1]
> https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AudioBufferSourceNode-section
>
>

Received on Tuesday, 20 March 2012 19:34:40 UTC