The disconnect() method of the AudioNode interface lets you disconnect one or more nodes from the node on which the method is called.
On this page
AudioNode: disconnect() method
Syntax
js
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.
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. 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). 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).
Return value
None (undefined).
Exceptions
IndexSizeErrorDOMException-
Thrown if the value specified as
inputoroutputis invalid, referring to a node which doesn't exist or is outside the permitted range. InvalidAccessErrorDOMException-
Thrown if the node on which
disconnect()is called isn't connected to the specifieddestinationnode.
Examples
js
const AudioContext = window.AudioContext || window.webkitAudioContext;
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
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
disconnect |
14 | 12 | 25 | No | 15 | 6 | 4.4.3 | 18 | 25 | 14 | 6 | 1.0 |
destination_parameter |
43 | ≤18 | No | No | 30 | No | 43 | 43 | No | 30 | No | 4.0 |
input_parameter |
43 | ≤18 | No | No | 30 | No | 43 | 43 | No | 30 | No | 4.0 |
See also
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AudioNode/disconnect