The channelInterpretation
property of the AudioNode
interface represents an enumerated value describing the meaning of the channels. This interpretation will define how audio up-mixing and down-mixing will happen.
When the number of channels doesn't match between an input and an output, up- or down-mixing happens according the following rules. This can be somewhat controlled by setting the AudioNode.channelInterpretation
property to speakers
or discrete
:
Interpretation | Input channels | Output channels | Mixing rules |
---|---|---|---|
speakers
|
1 (Mono)
|
2 (Stereo)
|
Up-mix from mono to stereo.
The |
1 (Mono)
|
4 (Quad)
|
Up-mix from mono to quad.
The | |
1 (Mono)
|
6 (5.1)
|
Up-mix from mono to 5.1.
The | |
2 (Stereo)
|
1 (Mono)
|
Down-mix from stereo to mono.
Both input channels ( | |
2 (Stereo)
|
4 (Quad)
|
Up-mix from stereo to quad.
The | |
2 (Stereo)
|
6 (5.1)
|
Up-mix from stereo to 5.1.
The | |
4 (Quad)
|
1 (Mono)
|
Down-mix from quad to mono.
All four input channels ( | |
4 (Quad)
|
2 (Stereo)
|
Down-mix from quad to stereo.
Both left input channels ( | |
4 (Quad)
|
6 (5.1)
|
Up-mix from quad to 5.1.
The | |
6 (5.1)
|
1 (Mono)
|
Down-mix from 5.1 to mono.
The left ( | |
6 (5.1)
|
2 (Stereo)
|
Down-mix from 5.1 to stereo.
The central channel ( | |
6 (5.1)
|
4 (Quad)
|
Down-mix from 5.1 to quad.
The central ( | |
Other, non-standard layouts | Non-standard channel layouts are handled as if channelInterpretation is set to discrete .
The specification explicitly allows the future definition of new speaker layouts. This fallback is therefore not future proof as the behavior of the browsers for a specific number 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. |
Syntax
var oscillator = audioCtx.createOscillator(); oscillator.channelInterpretation = 'discrete';
Value
An enumerated value representing a channelInterpretation.
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); oscillator.channelInterpretation = 'discrete';
Specifications
Specification | Status | Comment |
Web Audio APIThe definition of 'channelInterpretation' in that specification. | Working Draft |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
channelInterpretation
|
Chrome
Full support 14 |
Edge
Full support 12 |
Firefox
Full support 25 |
IE
No support No |
Opera
Full support 15 |
Safari
Full support 6 |
WebView Android
Full support Yes |
Chrome Android
Full support 18 |
Firefox Android
Full support 26 |
Opera Android
Full support 14 |
Safari iOS
Full support Yes |
Samsung Internet Android
Full support 1.0 |
Legend
- Full support
- Full support
- No support
- No support
See also
AudioNode.channelInterpretation by Mozilla Contributors is licensed under CC-BY-SA 2.5.