AudioWorkletNode()

The AudioWorkletNode() constructor creates a new AudioWorkletNode object, which represents an AudioNode with custom audio processing capabilities.

Syntax

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

Parameters

context
The BaseAudioContext instance this node will be associated with.
name
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's 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.

Exceptions

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

Example

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

Specifications

Specification Status Comment
Web Audio API
The definition of 'AudioWorkletNode()' in that specification.
Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
AudioWorkletNode() constructorChrome Full support 66Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android Full support 66Chrome Android Full support 66Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support Ā 
Full support
Compatibility unknown Ā 
Compatibility unknown

See also