The AudioWorkletNode() constructor creates a new AudioWorkletNode object, which represents an AudioNode that uses a JavaScript function to perform custom audio processing.


var node = new AudioWorkletNode(context, name);
var node = new AudioWorkletNode(context, name, options);


The BaseAudioContext instance this node will be associated with.
A string, which represents the name of the AudioWorkletProcessor this node will be based on. A processor with the provided name must first be registered using the AudioWorkletGlobalScope.registerProcessor() method.
options Optional
An object based on the AudioWorkletNodeOptions dictionary, which contains zero or more optional properties to configure the new node. The result of the structured clone algorithm applied to the object is also internally passed into the associated AudioWorkletProcessor() constructor — this allows custom initialization of an underlying user-defined AudioWorkletProcessor. Available properties are as follows:
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 its parameters property), with key being the name of a custom parameter and value being its initial value.
processorOptions Optional
Any additional data that can be used for custom initialization of the underlying AudioWorkletProcessor.

Return value

The newly constructed AudioWorkletNode instance.


The specified options.outputChannelCount is 0 or larger than the current implementation supports.
The length of options.outputChannelCount array does not match options.numberOfOutputs.


For a complete example demonstrating user-defined audio processing, see the AudioWorkletNode page.


Web Audio API
# dom-audioworkletnode-audioworkletnode

Browser compatibility

BCD tables only load in the browser

See also