AudioParamDescriptor

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 parameterDescriptors (en-US) static getter, then the returned array of objects based on this dictionary is used internally by AudioWorkletNode constructor to populate its parameters (en-US) property accordingly.

属性

name

The DOMString which represents the name of the AudioParam. Under this name the AudioParam will be available in the parameters (en-US) property of the node, and under this name the AudioWorkletProcessor.process (en-US) method will acquire the calculated values of this AudioParam.

automationRate 可选

Either "a-rate", or "k-rate" string which represents an automation rate of this AudioParam. Defaults to "a-rate".

minValue 可选

A float which represents minimum value of the AudioParam. Defaults to -3.4028235e38.

maxValue 可选

A float which represents maximum value of the AudioParam. Defaults to 3.4028235e38.

defaultValue 可选

A float which represents initial value of the AudioParam. Defaults to 0.

示例

下面的代码片段展示了自定义的 AudioWorkletProcessor 中的静态方法 parameterDescriptors (en-US) 返回该类型的描述符(这是 AudioWorkletNode.parameters (en-US) 中完整示例的一部分)。

// white-noise-processor.js
class WhiteNoiseProcessor extends AudioWorkletProcessor {
  static get parameterDescriptors () {
    return [{
      name: 'customGain',
      defaultValue: 1,
      minValue: 0,
      maxValue: 1,
      automationRate: 'a-rate'
    }]
  }

// …
}

规范

No specification found

No specification data found for api.AudioParamDescriptor.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

浏览器兼容性

No compatibility data found for api.AudioParamDescriptor.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.