Path: blob/main/files/en-us/web/api/audioworkletnode/parameters/index.md
6520 views
------{{APIRef("Web Audio API")}}
The read-only parameters property of the {{domxref("AudioWorkletNode")}} interface returns the associated {{domxref("AudioParamMap")}} — that is, a Map-like collection of {{domxref("AudioParam")}} objects. They are instantiated during creation of the underlying {{domxref("AudioWorkletProcessor")}} according to its {{domxref("AudioWorkletProcessor.parameterDescriptors", "parameterDescriptors")}} static getter.
Value
The {{domxref("AudioParamMap")}} object containing {{domxref("AudioParam")}} instances. They can be automated in the same way as with default AudioNodes, and their calculated values can be used in the {{domxref("AudioWorkletProcessor.process", "process")}} method of your {{domxref("AudioWorkletProcessor")}}.
Examples
To demonstrate creation and usage of custom AudioParams, we'll expand the example from {{domxref("AudioWorkletNode")}} page. There we've created a simple node which outputs white noise. Here, additionally, we'll create a custom gain parameter, so we can directly change volume of the output (although you could use {{domxref("GainNode")}} to achieve this as well).
First, we need to define a custom AudioWorkletProcessor, and register it. Note that this should be done in a separate file.
We expand the processor by adding a static {{domxref("AudioWorkletProcessor.parameterDescriptors", "parameterDescriptors")}} getter. It will be used internally by the AudioWorkletNode constructor to populate its parameters with instantiated AudioParam objects.
Next, in our main scripts file we'll load the processor, create an instance of AudioWorkletNode passing it the name of the processor, and connect the node to an audio graph.
Now we can change the gain on the node like this:
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}