Skip to content Skip to sidebar Skip to footer

Why Does The Stop Method In Audiobuffernode Destroy It?

We know that when you invoke #.stop() on an AudioBufferNode, you cannot then #.start(). Why is the behavior so? This issue came up when playing around with WebAudio API as we all f

Solution 1:

You're not calling .stop() on an AudioBuffer, you're calling .stop() on a BufferSourceNode - the AudioBuffer can be used multiple times.

The short version is it's an optimization that allows for fire-and-forget playback of buffers in a very lightweight way - you can build a higher level media player around it, but in and of itself BufferSourceNodes are very lightweight. The sound data itself is not forgotten, and can be reused - in fact, used simultaneously by other BufferSourceNodes - because it's in the separate AudioBuffer object.


Post a Comment for "Why Does The Stop Method In Audiobuffernode Destroy It?"