Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to disconnect an Oscillator AudioNode after stop it?

I had seen in several tutorials people using .disconnect() after an .stop() in Oscillators Nodes.

As far as I understand, an Oscillator Node is disposable so when it stop and get thrown away, doesn't it get disconnected too?

Am I understanding something wrong? Why do I need to use .disconnect() after an .stop() ?

like image 463
distante Avatar asked Apr 14 '16 15:04

distante


2 Answers

According to the W3C Specification:

When an AudioNode has no references it will be deleted. Before it is deleted, it will disconnect itself from any other AudioNodes which it is connected to.

So when an AudioNode get stopped and no references are left it will disconnect itself and it is thus not needed to explicitly call disconnect() after stop().

like image 126
Tomasito665 Avatar answered Oct 26 '22 13:10

Tomasito665


You shouldn't need to disconnect the oscillator after stop(). In fact, after scheduling the start and stop times of the oscillator, you should be able to drop the reference to the oscillator immediately and the oscillator should still play. After stopping, it should automatically disconnect itself.

Of course there could be bugs in the implementation that makes disconnect to the right thing. But that's a bug.

like image 20
Raymond Toy Avatar answered Oct 26 '22 12:10

Raymond Toy