RE: replay AudioBufferSourceNode ?

I think your confusion comes from the feature of dynamic lifetime of AudioBufferSourceNode. 

>From the spec: 
"The audio system automatically deals with tearing-down the part of the routing graph for individual "note" events. A "note" is represented by an AudioBufferSourceNode, which can be directly connected to other processing nodes. When the note has finished playing, the context will automatically release the reference to the AudioBufferSourceNode, which in turn will release references to any nodes it is connected to, and so on. The nodes will automatically get disconnected from the graph and will be deleted when they have no more references. Nodes in the graph which are long-lived and shared between dynamic voices can be managed explicitly. Although it sounds complicated, this all happens automatically with no extra JavaScript handling required."

As stated in the spec: Although it sounds complicated, this all happens automatically with no extra JavaScript handling required.

Best Regards 

James 



-----Original Message-----
From: Jerome Etienne [mailto:jerome.etienne@gmail.com] 
Sent: Wednesday, March 21, 2012 12:31 PM
To: Chris Rogers
Cc: public-audio@w3.org
Subject: Re: replay AudioBufferSourceNode ?

On Tue, Mar 20, 2012 at 8:34 PM, Chris Rogers <crogers@google.com> wrote:
> On Tue, Mar 20, 2012 at 12:29 AM, Jerome Etienne 
> <jerome.etienne@gmail.com>
>> 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/

i read this tutorial. in fact i read all tutorials about webaudio i could find on html5rock. i failed to find one which explain how to
*clone* a buffersource, aka copy an existing buffersource. i only found how to *create* one. did i miss it ?

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

I asuppose i want to play a sound several time ? how can i do that ?
what is the recommended way ?

Is it to create a function which init the buffersource node, and call it to recreate the node at every occurance ? how to do that efficiently ?

Received on Wednesday, 21 March 2012 06:19:47 UTC