AudioNode: disconnect() method
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
The disconnect()
method of the AudioNode
interface lets you disconnect one or more nodes from the node on which the method is called.
Syntax
disconnect()
Parameters
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-
An
AudioNode
orAudioParam
specifying the node or nodes to disconnect from. If this value is anAudioNode
, a single node is disconnected from, with any other, optional, parameters (output
and/orinput
) further limiting which inputs and/or outputs should be disconnected. If this value is anAudioParam
, then the connection to thatAudioParam
is terminated, and the node's contributions to that computed parameter become 0 going forward once the change takes effect. output
Optional-
An index describing which output from the current
AudioNode
is to be disconnected. The index numbers are defined according to the number of output channels (see Audio channels). input
Optional-
An index describing which input into the specified destination
AudioNode
is to be disconnected. The index numbers are defined according to the number of input channels (see Audio channels).
Return value
None (undefined
).
Exceptions
IndexSizeError
DOMException
-
Thrown if the value specified as
input
oroutput
is invalid, referring to a node which doesn't exist or is outside the permitted range. InvalidAccessError
DOMException
-
Thrown if the node on which
disconnect()
is called isn't connected to the specifieddestination
node.
Examples
const audioCtx = new AudioContext();
const oscillator = audioCtx.createOscillator();
const gainNode = audioCtx.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioCtx.destination);
gainNode.disconnect();
Specifications
Specification |
---|
Web Audio API # dom-audionode-disconnect |
Browser compatibility
BCD tables only load in the browser