Search code examples
javascriptweb-audio-api

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() ?


Solution

  • 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().