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()
?
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()
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With