W3C home > Mailing lists > Public > public-audio@w3.org > January to March 2012

Re: replay AudioBufferSourceNode ?

From: Chris Rogers <crogers@google.com>
Date: Tue, 20 Mar 2012 12:34:07 -0700
Message-ID: <CA+EzO0kot2-t6Bnv__gZqO+_J=7RZQCJRQDiVA99mPHF_V_SAg@mail.gmail.com>
To: Jerome Etienne <jerome.etienne@gmail.com>
Cc: public-audio@w3.org
On Tue, Mar 20, 2012 at 12:29 AM, Jerome Etienne

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

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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:49:58 UTC