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.
destinationOptional- An
AudioNodeorAudioParamspecifying the node or nodes to disconnect from. If this value is anAudioNode, a single node is disconnected from, with any other, optional, parameters (outputand/orinput) further limiting which inputs and/or outputs should be disconnected. If this value is anAudioParam, then the connection to thatAudioParamis 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, anInvalidAccessErrorexception is thrown. outputOptional- An index describing which output from the current
AudioNodeis 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, anIndexSizeErrorexception is thrown. inputOptional- An index describing which input into the specified destination
AudioNodeis 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, anIndexSizeErrorexception is thrown.
Exceptions
IndexSizeError- A value specified for
inputoroutputis 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 specifieddestinationnode.
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
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|---|
| Basic support | 10.0webkit | (Yes) | 25 (25) | No support | 15.0webkit 22 (unprefixed) |
(Yes) |
destination and input parameters |
43.0 | (Yes) | No support | ? | ? | ? |
| Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | Firefox OS (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
|---|---|---|---|---|---|---|---|---|---|
| Basic support | ? | ? | (Yes) | 25.0 (25) | 1.2 | ? | ? | ? | ? |
| destination and input parameters | No support | No support | (Yes) | No support | No support | ? | ? | ? | 43.0 |
See also
Document Tags and Contributors
Tags:
Contributors to this page:
arronei,
TrevorBurnham,
erikadoyle,
Sheppy,
1j01,
Yukulele.,
Jeremie,
jpmedley,
fscholz,
padenot,
chrisdavidmills
Last updated by:
arronei,