This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
The registerProcessor method of the AudioWorkletGlobalScope interface registers a class constructor derived from AudioWorkletProcessor interface under a specified name.
registerProcessor(name, processorCtor)
nameA string representing the name under which the processor will be registered.
processorCtorThe constructor of a class derived from AudioWorkletProcessor.
Note: A key-value pair { name: constructor } is saved internally in the AudioWorkletGlobalScope once the processor is registered. The name is to be referred to when creating an AudioWorkletNode based on the registered processor. A new processor by the given name is internally created and associated with the new node.
None (undefined).
NotSupportedError DOMException
Thrown under the following conditions:
TypeErrorThrown under the following conditions:
parameterDescriptors property of the constructor exists and doesn't return an array of AudioParamDescriptor-based objects.In this example we create a custom AudioWorkletNode that outputs silence.
First, we need to define a custom AudioWorkletProcessor and register it. Note that this should be done in a separate file.
// test-processor.js
class TestProcessor extends AudioWorkletProcessor {
process(inputs, outputs, parameters) {
return true;
}
}
registerProcessor("test-processor", TestProcessor);
Next, in our main script file we'll load the processor, create an instance of AudioWorkletNode — passing it the processor name that we used when calling registerProcessor — and connect it to an audio graph.
const audioContext = new AudioContext();
await audioContext.audioWorklet.addModule("test-processor.js");
const node = new AudioWorkletNode(audioContext, "test-processor");
node.connect(audioContext.destination);
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
registerProcessor |
66 | 79 | 76 | 53 | 14.1 | 66 | 79 | 47 | 14.5 | 9.0 | 66 | 14.5 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletGlobalScope/registerProcessor