The AudioWorkletNodeOptions
dictionary of the Web Audio API is used to specify configuration options when constructing a new AudioWorkletNode
object for custom audio processing. It is only used when calling the AudioWorkletNode()
constructor. During internal instantiation of the underlying AudioWorkletProcessor
, the the structured clone algorithm is applied to the options object and the result is passed into AudioWorkletProcessor
's constructor.
Properties
numberOfInputs
Optional- The value to initialize the
numberOfInputs
property to. Defaults to 1. numberOfOutputs
Optional- The value to initialize the
numberOfOutputs
property to. Defaults to 1. outputChannelCount
Optional- An array defining the number of channels for each output. For example, outputChannelCount: [n, m] specifies the number of channels in the first output to be n and the second output to be m. The array length must match
numberOfOutputs
. parameterData
Optional- An object containing the initial values of custom
AudioParam
objects on this node (in itsparameters
property), withkey
being the name of a custom parameter andvalue
being its initial value. processorOptions
Optional- Any additional data that can be used for custom initialization of the underlying
AudioWorkletProcessor
.
Usage notes
When creating an AudioWorkletNode
, these options can have various effects. If the number of inputs and number of outputs are both set to 0, a NotSupportedError
will be thrown and the node construction process aborted. If the length of the outputChannelCount
array doesn't match numberOfOutputs
, an IndexSizeError
will be thrown.
If outputChannelCount
isn't specified, and numberOfInputs
and numberOfOutputs
are both 1, the AudioWorkletNode
's initial channel count is set to 1. This has the effect of changing the output channel count to dynamically change to the computed number of channels, based on the input's channel count and the current setting of the AudioNode
property channelCountMode
.
Otherwise, if outputChannelCount
is provided and if the values of numberOfInputs
and numberOfOutputs
are both 1, the audio worklet node's channel count is set to the value of outputChannelCount
. Otherwise, the channel count of each channel in the set of output channels is set to match the corresponding value in the outputChannelCount
array.
Examples
// FILL IN EXAMPLE SNIPPET
Specifications
Specification | Status | Comment |
Web Audio APIThe definition of 'AudioWorkletNodeOptions' in that specification. | Working Draft | Initial definition. |
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.
No compatibility data found. Please contribute data for "api.AudioWorkletNodeOptions" (depth: 1) to the MDN compatibility data repository.
AudioWorkletNodeOptions by Mozilla Contributors is licensed under CC-BY-SA 2.5.