files/en-us/web/api/audionode/disconnect/index.md
{{ APIRef("Web Audio API") }}
The disconnect() method of the {{ domxref("AudioNode") }} interface lets you disconnect one or more nodes from the node on which the method is called.
disconnect()
disconnect(output)
disconnect(destination)
disconnect(destination, output)
disconnect(destination, output, input)
There are several versions of the disconnect() method, which accept different combinations of parameters to control which nodes to disconnect from. If no parameters are provided, all outgoing connections are disconnected.
destination {{optional_inline}}
AudioNode, a single node is disconnected from, with any other, optional, parameters (output and/or input) further limiting which inputs and/or outputs should be disconnected. If this value is an AudioParam, then the connection to that AudioParam is terminated, and the node's contributions to that computed parameter become 0 going forward once the change takes effect.output {{optional_inline}}
AudioNode is to be disconnected. The index numbers are defined according to the number of output channels (see Audio channels).input {{optional_inline}}
AudioNode is to be disconnected. The index numbers are defined according to the number of input channels (see Audio channels). Not applicable if destination is an AudioParam.None ({{jsxref("undefined")}}).
IndexSizeError {{domxref("DOMException")}}
input or output is invalid, referring to a node which doesn't exist or is outside the permitted range.InvalidAccessError {{domxref("DOMException")}}
disconnect() is called isn't connected to the specified destination node.const audioCtx = new AudioContext();
const oscillator = audioCtx.createOscillator();
const gainNode = audioCtx.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioCtx.destination);
gainNode.disconnect();
{{Specifications}}
{{Compat}}