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
AudioNodeyou are connecting to. - output Optional
- An index describing which output of the current
AudioNodeyou 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_ERRexception is thrown. It is possible to connect anAudioNodeoutput 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
AudioNodeto. The index numbers are defined according to the number of input channels (see Audio channels). If this parameter is out-of-bound, anINDEX_SIZE_ERRexception is thrown. It is possible to connect anAudioNodeto anotherAudioNode, which in turn connects back to the firstAudioNode, creating a cycle. This is allowed only if there is at least oneDelayNodein the cycle. Otherwise, aNOT_SUPPORTED_ERRexception 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) |