The disconnect()
method of the AudioNode
interface lets you disconnect one or more nodes from the node on which the method is called.
Syntax
AudioNode.disconnect(); AudioNode.disconnect(output); AudioNode.disconnect(destination); AudioNode.disconnect(destination, output); AudioNode.disconnect(destination, output, input);
Return value
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. If no matching connection is found, anInvalidAccessError
exception is thrown. 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). If this parameter is out-of-bound, anIndexSizeError
exception is thrown. 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). If this parameter is out-of-bound, anIndexSizeError
exception is thrown.
Exceptions
IndexSizeError
- A value specified for
input
oroutput
is invalid, referring to a node which doesn't exist or outside the permitted range. InvalidAccessError
- The node on which
disconnect()
was called isn't connected to the specifieddestination
node.
Example
var AudioContext = window.AudioContext || window.webkitAudioContext; var audioCtx = new AudioContext(); var oscillator = audioCtx.createOscillator(); var gainNode = audioCtx.createGain(); oscillator.connect(gainNode); gainNode.connect(audioCtx.destination); gainNode.disconnect();
Specifications
Specification | Status | Comment |
---|---|---|
Web Audio API The definition of 'disconnect' in that specification. |
Working Draft |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
disconnect | Chrome Full support 14 | Edge Full support 12 | Firefox Full support 25 | IE No support No | Opera Full support 15 | Safari Full support 6 | WebView Android Full support Yes | Chrome Android Full support 18 | Firefox Android Full support 26 | Opera Android Full support 14 | Safari iOS Full support Yes | Samsung Internet Android Full support 1.0 |
destination parameter | Chrome Full support 43 | Edge Full support ≤18 | Firefox No support No | IE No support No | Opera ? | Safari No support No | WebView Android Full support 43 | Chrome Android Full support 43 | Firefox Android No support No | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 4.0 |
input parameter | Chrome Full support 43 | Edge Full support ≤18 | Firefox No support No | IE No support No | Opera ? | Safari No support No | WebView Android Full support 43 | Chrome Android Full support 43 | Firefox Android No support No | Opera Android ? | Safari iOS ? | Samsung Internet Android Full support 4.0 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown