Web Audio API
The AudioParamDescriptor dictionary of the Web Audio API specifies properties for an AudioParam objects. It is used to create custom AudioParams on an AudioWorkletNode. If the underlying AudioWorkletProcessor has a AudioWorkletProcessor.parameterDescriptors static getter, then the returned array of objects based on this dictionary is used internally by AudioWorkletNode constructor to populate its AudioWorkletNode.parameters property accordingly.
属性
name- : The String which represents the name of the
AudioParam. Under this name theAudioParamwill be available in the AudioWorkletNode.parameters property of the node, and under this name the AudioWorkletProcessor.process method will acquire the calculated values of thisAudioParam.
- : The String which represents the name of the
automationRateminValue- : A
floatwhich represents minimum value of theAudioParam. Defaults to-3.4028235e38.
- : A
maxValue- : A
floatwhich represents maximum value of theAudioParam. Defaults to3.4028235e38.
- : A
defaultValue- : A
floatwhich represents initial value of theAudioParam. Defaults to0.
- : A
示例
下面的代码片段展示了自定义的 AudioWorkletProcessor 中的静态方法 AudioWorkletProcessor.parameterDescriptors 返回该类型的描述符(这是 AudioWorkletNode.parameters 中完整示例的一部分)。
// white-noise-processor.js
class WhiteNoiseProcessor extends AudioWorkletProcessor {
static get parameterDescriptors() {
return [
{
name: "customGain",
defaultValue: 1,
minValue: 0,
maxValue: 1,
automationRate: "a-rate",
},
];
}
// …
}
规范
浏览器兼容性
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
