AudioNode - Web API 接口参考 编辑
这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。
AudioNode
接口是一个处理音频的通用模块, 比如一个音频源 (e.g. 一个 HTML <audio>
or <video>
元素), 一个音频地址或者一个中间处理模块 (e.g. 一个过滤器如 BiquadFilterNode
, 或一个音量控制器如 GainNode
).
一个AudioNode
既有输入也有输出。输入与输出都有一定数量的通道。只有一个输出而没有输入的 AudioNode
叫做音频源。
处理多个 AudioNode
时,一般来说, 一个模块读取它的输入,做一些处理。后输出新生成的结果。
不同的模块可以连接在一起构建一个处理图。 这样一个处理图包含 AudioContext
。 每个 AudioNode
只有一个这样的上下文。
一个 AudioNode
可以作为事件的目标,所以它实现了 EventTarget
接口。
属性
AudioNode.context
只读- 链接到关联的
AudioContext
,处理图中模块的上下文对象。
AudioNode.numberOfInputs
只读- 返回这个node需要的输入数量. Source nodes are defined as nodes having a
numberOfInputs
attributes with a value of0
.
AudioNode.numberOfOutputs
只读- 返回这个node的输出数量. Destination nodes, like
AudioDestinationNode
, have a value of0
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 happensGainNode
,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:
When the amount of channels doesn't match between an input and an output, up- or down-mixing happens according the following rules:Mono 0: M: mono
Stereo 0: L: left
1: R: rightQuad 0: L: left
1: R: right
2: SL: surround left
3: SR: surround right5.1 0: L: left
1: R: right
2: C: center
3: LFE: subwoofer
4: SL: surround left
5: SR: surround rightInterpretation Input channels Output channels Mixing rules speakers
1
(Mono)2
(Stereo)Up-mix from mono to stereo.
TheM
input channel is used for both output channels (L
andR
).output.L = input.M
output.R = input.M1
(Mono)4
(Quad)Up-mix from mono to quad.
TheM
input channel is used for non-surround output channels (L
andR
). Surround output channels (SL
andSR
) are silent.output.L = input.M
output.R = input.M
output.SL = 0
output.SR = 01
(Mono)6
(5.1)Up-mix from mono to 5.1.
TheM
input channel is used for the center output channel (C
). All the others (L
,R
,LFE
,SL
, andSR
) are silent.output.L = 0
output.R = 0output.C = input.M
output.LFE = 0
output.SL = 0
output.SR = 02
(Stereo)1
(Mono)Down-mix from stereo to mono.
Both input channels (L
andR
) 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.
TheL
andR
input channels are used for their non-surround respective output channels (L
andR
). Surround output channels (SL
andSR
) are silent.output.L = input.L
output.R = input.R
output.SL = 0
output.SR = 02
(Stereo)6
(5.1)Up-mix from stereo to 5.1.
TheL
andR
input channels are used for their non-surround respective output channels (L
andR
). Surround output channels (SL
andSR
), 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 = 04
(Quad)1
(Mono)Down-mix from quad to mono.
All four input channels (L
,R
,SL
, andSR
) 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
andSL
) are equally combined to produce the unique left output channel (L
). And similarly, both right input channels (R
andSR
) 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.
TheL
,R
,SL
, andSR
input channels are used for their respective output channels (L
andR
). 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.SR6
(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
orSR
) 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
andR
). 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.SROther As these are non-standard channel layout, they are handled as if channelInterpretation
was set todiscrete
.
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
) wherex<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
) wherex>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.
方法
Also implements methods from the interface EventTarget
.
AudioNode.connect(AudioNode)
- 允许将此节点的一个输出连接到另一个节点的一个输入。
AudioNode.connect(AudioParam)
- 允许将此节点的一个输出连接到音频参数的一个输入。
AudioNode.disconnect()
- 允许将这个节点从另一个节点断开连接。
例子
规范
Specification | Status | Comment |
---|---|---|
Web Audio API AudioNode | Working Draft |
浏览器兼容性
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | (Yes)webkit | Activated on Nightly only | 未实现 | 未实现 | ? |
channelCount channelCountMode | 未实现 | 未实现 (?) | 未实现 | 未实现 | 未实现 |
connect (AudioParam) | 未实现 | Activated on Nightly only | 未实现 | 未实现 | 未实现 |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | 未实现 | Activated on Nightly only | 未实现 | 未实现 | ? |
channelCount channelCountMode | 未实现 | 未实现 (?) | 未实现 | 未实现 | 未实现 |
connect (AudioParam) | 未实现 | Activated on Nightly only | 未实现 | 未实现 | 未实现 |
相关内容
- Using Web Audio
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论