Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

AudioNode — audio graph nodes and connections

AudioNode is the base interface for Web Audio nodes. Its connect() method routes audio processing or controls an audio parameter.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

node.connect(destinationNode) // returns destinationNode
node.connect(destinationNode, output) // returns destinationNode
node.connect(destinationNode, output, input) // returns destinationNode
node.connect(destinationParam) // returns undefined
node.connect(destinationParam, output) // returns undefined
// Omitted output and input indices default to 0.

AudioNode is the base interface for sources, processors, and outputs in a Web Audio graph. Create concrete nodes, for example through context.createGain(), rather than new AudioNode(). This is a browser API, not part of ECMAScript; having Node 24 does not establish its availability.

AudioNode.connect, called as node.connect(...), connects an output to another node's input or to an AudioParam. The node overload returns the destination, enabling chaining; the AudioParam overload returns undefined. Port indices default to 0; they are not channel numbers. Different contexts cause InvalidAccessError, and out-of-range indices cause IndexSizeError. Repeating an identical connection is ignored.

Examples

(async () => {
  const context = new OfflineAudioContext(1, 128, 48000);
  const buffer = context.createBuffer(1, 128, 48000);
  buffer.getChannelData(0).fill(1);

  const source = context.createBufferSource();
  source.buffer = buffer;
  const gain = context.createGain();
  gain.gain.value = 0.5;

  source.connect(gain).connect(context.destination);
  source.start(0);

  const rendered = await context.startRendering();
  const samples = rendered.getChannelData(0);
  console.log(samples.length, samples.every(value => value === 0.5));
})().catch(console.error);

Result

128 true

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources