The connect
method of the AudioNode
interface allows you to connect one output of the current node to one input of another node.
Syntax
var AudioNode = AudioNode.connect(destination, output, input)
Parameters
- destination
- The
AudioNode
you are connecting to. - output Optional
- An index describing which output of the current
AudioNode
you want to connect to the destination. The index numbers are defined according to the number of output channels (see Audio channels). If this parameter is out-of-bound, anINDEX_SIZE_ERR
exception is thrown. It is possible to connect anAudioNode
output to more than one input with multiple calls toconnect()
. Therefore fan-out is supported. - input Optional
- An index describing which input of the destination you want to connect the current
AudioNode
to. The index numbers are defined according to the number of input channels (see Audio channels). If this parameter is out-of-bound, anINDEX_SIZE_ERR
exception is thrown. It is possible to connect anAudioNode
to anotherAudioNode
, which in turn connects back to the firstAudioNode
, creating a cycle. This is allowed only if there is at least oneDelayNode
in the cycle. Otherwise, aNOT_SUPPORTED_ERR
exception will be thrown.
Returns
A reference to the destination AudioNode
object. In some browsers older implementations of this interface return void.
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);
Specifications
Specification | Status | Comment |
---|---|---|
Web Audio API The definition of 'connect(AudioNode)' in that specification. |
Working Draft |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 10.0webkit | 25.0 (25.0) | Not supported | 15.0webkit | (Yes) |
Unprefixed | (Yes) | 22 |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | ? | ? | 26.0 | 1.2 | ? | ? | ? | ? |
Unprefixed | ? | (Yes) | (Yes) |