AudioNode

« Web Audio API

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

AudioNodes participating in an AudioContext create a audio routing graph.The AudioNode interface represents an audio-processing module, like an audio source (e.g. an HTML <audio> or <video> element), an audio destination, or an intermediate processing module (e.g. a filter like BiquadFilterNode, or a volume control like GainNode).

An AudioNode has inputs and outputs. Each of them have a given amount of channels. An AudioNode with zero input and exactly one output is called a source node.

The processing varies from one AudioNode to another but, in general, a node reads its inputs, does some audio-related processing, and generates new values on its output.

Different nodes can be linked together to build a processing graph. Such a graph is contained in an AudioContext. Each AudioNode participates in exactly one such context.

An AudioNode can be target of events, therefore it implements the EventTarget interface.

Properties

AudioNode.context Read only
Links to the associated AudioContext, that is the object representing the processing graph the node is participating in.
AudioNode.numberOfInputs Read only
Returns the amount of inputs feeding the node. Source nodes are defined as nodes having a numberOfInputs attributes with a value of 0.
AudioNode.numberOfOutputs Read only
Returns the amount of outputs coming out of the node. Destination nodes, like AudioDestinationNode, have a value of 0 for this attribute.
AudioNode.channelCount
Represents an integer used in determining how many channels outputs must contains. Its usage and precise definition depends of the value of AudioNode.channelCountMode: it is ignored if the value is "max", used as a maximum value for "clamped-max", or used as the effective value for "explicit".
AudioNode.channelCountMode
Represents an enumerated value describing the way channels must be matched between the inputs and the outputs. Possible values are:
Value Description Used as default for the following AudioNode children
"max" The number of channels is the maximum of the number of channels all connections. That implies that channelCount is ignored and only up-mixing happens GainNode, DelayNode, ScriptProcessorNode, ChannelSplitterNode, ChannelMergerNode, BiquadFilterNode, WaveShaperNode
"clamped-max" The number of channels is the maximum of the number of channels of all connections, clamped to the value of channelCount. PannerNode, ConvolverNode
"explicit" The number of channels is defined by the value of channelCount. AudioDestinationNode, AnalyserNode, DynamicsCompressorNode
AudioNode.channelInterpretation
Represents an enumerated value describing the meaning of the channels. This interpretation will define how the up-mixing and the down-mixing will happen.
The possible values are "speakers" or "discrete". In the case of "speakers", the ordering of the channels have the following meaning, and the channels are often represented by a standard abbreviation:
Mono 0: M: mono
Stereo 0: L: left
1: R: right
Quad 0: L:  left
1: R:  right
2: SL: surround left
3: SR: surround right
5.1 0: L:   left
1: R:   right
2: C:   center
3: LFE: subwoofer
4: SL:  surround left
5: SR:  surround right
When the amount of channels doesn't match between an input and an output, up- or down-mixing happens according the following rules:
Interpretation Input channels Output channels Mixing rules
speakers 1 (Mono) 2 (Stereo) Up-mix from mono to stereo.
The M input channel is used for both output channels (L and R).
output.L = input.M
output.R = input.M
1 (Mono) 4 (Quad) Up-mix from mono to quad.
The M input channel is used for non-surround output channels (L and R). Surround output channels (SL and SR) are silent.
output.L  = input.M
output.R  = input.M
output.SL = 0
output.SR = 0
1 (Mono) 6 (5.1) Up-mix from mono to 5.1.
The M input channel is used for the center output channel (C). All the others (L, R, LFE, SL, and SR) are silent.
output.L   = 0
output.R   = 0

output.C   = input.M
output.LFE = 0
output.SL  = 0
output.SR  = 0
2 (Stereo) 1 (Mono) Down-mix from stereo to mono.
Both input channels (L and R) are equally combined to produce the unique output channel (M).
output.M = 0.5 * (input.L + input.R)
2 (Stereo) 4 (Quad) Up-mix from stereo to quad.
The L and R input channels are used for their non-surround respective output channels (L and R). Surround output channels (SL and SR) are silent.
output.L  = input.L
output.R  = input.R
output.SL = 0
output.SR = 0
2 (Stereo) 6 (5.1) Up-mix from stereo to 5.1.
The L and R input channels are used for their non-surround respective output channels (L and R). Surround output channels (SL and SR), as well as the center (C) and subwoofer (LFE) channels, are left silent.
output.L   = input.L
output.R   = input.R
output.C   = 0
output.LFE = 0
output.SL  = 0
output.SR  = 0
4 (Quad) 1 (Mono) Down-mix from quad to mono.
All four input channels (L, R, SL, and SR) are equally combined to produce the unique output channel (M).
output.M = 0.25 * (input.L + input.R + input.SL + input.SR)
4 (Quad) 2 (Stereo) Down-mix from quad to mono.
Both left input channels (L and SL) are equally combined to produce the unique left output channel (L). And similarly, both right input channels (R and SR) are equally combined to produce the unique right output channel (R).
output.L = 0.5 * (input.L + input.SL)
output.R = 0.5 * (input.R + input.SR)
4 (Quad) 6 (5.1) Up-mix from quad to 5.1.
The L, R, SL, and SR input channels are used for their respective output channels (L and R). Center (C) and subwoofer (LFE) channels are left silent.
output.L   = input.L
output.R   = input.R
output.C   = 0
output.LFE = 0
output.SL  = input.SL
output.SR  = input.SR
6 (5.1) 1 (Mono) Down-mix from 5.1 to stereo.
The left and right, both surround or not, and the central channels are all mixed together. The surround channels are slightly attenuated and the regular lateral channels are power-compensated to make them count as a single channel. The subwoofer (LFE) channel is lost.
output.M = 0.7071 * (input.L + input.R) + input.C + 0.5 * (input.SL + input.SR)
6 (5.1) 2 (Stereo) Down-mix from 5.1 to stereo.
The central (C) is summed with each lateral surround channels (SL or SR) and mixed to each lateral channel. As it is mixed in two channels, it is mixed at lower power, that is they are multiplied by √2/2. The subwoofer (LFE) channel is lost.
output.L   = input.L + 0.7071 * (input.C + input.SL)
output.R   = input.R
+ 0.7071 * (input.C + input.SR)
6 (5.1) 4 (Quad) Down-mix from 5.1 to quad.
The central (C) is mixed with the lateral non-surround channels (L and R). As it is mixed in two channels, it is mixed at lower power, that is they are multiplied by √2/2. The surround channels are passed unchanged. The subwoofer (LFE) channel is lost.
output.L   = input.L + 0.7071 * input.C
output.R   = input.R
output.SL  = input.SL
output.SR  = input.SR
Other As these are non-standard channel layout, they are handled as if channelInterpretation was set to discrete.
The specification explicitly allow the future definition of new speakers layout. This fallback is therefore not future proof as the behavior of the browsers for a specific amount of channels may change in the future.
discrete any (x) any (y) where x<y Up-mix discrete channels.
Fill each output channel with its input counterpart, that is the input channel with the same index. Channels with no corresponding input channels are left silent.
any (x) any (y) where x>y Down-mix discrete channels.
Fill each output channel with its input counterpart, that is the input channel with the same index. Input channels with no corresponding output channels are dropped.

Methods

Also implements methods from the interface EventTarget.

AudioNode.connect(AudioNode)
Allows to connect one output of this node to one input of another node.
AudioNode.connect(AudioParam)
Allows to connect one output of this node to one input of an audio parameter.
AudioNode.disconnect()
Allows to disconnect this node from another one.

Examples

 

Specifications

Specification Status Comment
Web Audio API Working Draft  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes)webkit Activated on Nightly only Not supported Not supported ?
channelCount channelCountMode Not supported Not supported (?) Not supported Not supported Not supported
connect(AudioParam) Not supported Activated on Nightly only Not supported Not supported Not supported
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support Not supported Activated on Nightly only Not supported Not supported ?
channelCount
channelCountMode
Not supported Not supported (?) Not supported Not supported Not supported
connect(AudioParam) Not supported Activated on Nightly only Not supported Not supported Not supported

See also

  • Using Web Audio

Attachments

File Size Date Attached by
AudioNode relationships in an AudioContext
AudioNodes participating in an AudioContext create a audio routing graph.
50448 bytes 2013-04-08 02:44:06 teoli

Document Tags and Contributors

Contributors to this page: Sheppy, ethertank, kscarfone, teoli
Last updated by: kscarfone,