Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. AudioWorkletNode
  4. AudioWorkletNode()

AudioWorkletNode: AudioWorkletNode() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨April 2021⁩.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

TheAudioWorkletNode()constructor creates a newAudioWorkletNode object, which represents anAudioNode that uses a JavaScript function to perform custom audioprocessing.

Syntax

js
new AudioWorkletNode(context, name)new AudioWorkletNode(context, name, options)

Parameters

context

TheBaseAudioContext instance this node will be associated with.

name

A string, which represents the name of theAudioWorkletProcessor thisnode will be based on. A processor with the provided name must first be registeredusing theAudioWorkletGlobalScope.registerProcessor() method.

optionsOptional

An object containing zero or more of the following optional properties to configure the new node:

Note:The result ofthe structured clone algorithmapplied to the object is also internally passed into the associatedAudioWorkletProcessor() constructor— this allows custom initialization of an underlying user-definedAudioWorkletProcessor.

numberOfInputsOptional

The value to initialize thenumberOfInputs property to. Defaults to 1.

numberOfOutputsOptional

The value to initialize thenumberOfOutputs property to. Defaults to 1.

outputChannelCountOptional

Anarray defining the number of channels for each output. For example,outputChannelCount: [n, m] specifies the number of channels in the first output to ben and the second output to bem. The array length must matchnumberOfOutputs.

parameterDataOptional

An object containing the initial values of customAudioParam objects on this node (in itsparameters property), withkey being the name of a custom parameter andvalue being its initial value.

processorOptionsOptional

Any additional data that can be used for custom initialization of the underlyingAudioWorkletProcessor.

Exceptions

NotSupportedErrorDOMException

The specifiedoptions.outputChannelCount is0 or largerthan the current implementation supports.

Bothoptions.numberOfInputs andoptions.numberOfOutputs are 0.

IndexSizeErrorDOMException

The length ofoptions.outputChannelCount array does not matchoptions.numberOfOutputs.

Usage notes

Differentoptions parameter values can have the following effects.

If the number of inputs and number of outputs are both set to 0, aNotSupportedError will be thrown and the node construction process aborted. If the length of theoutputChannelCount array doesn't matchnumberOfOutputs, anIndexSizeErrorDOMException will be thrown.

IfoutputChannelCount isn't specified, andnumberOfInputs andnumberOfOutputs are both 1, theAudioWorkletNode'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 theAudioNode propertychannelCountMode.

Otherwise, ifoutputChannelCount is providedand if the values ofnumberOfInputs andnumberOfOutputs are both 1, the audio worklet node's channel count is set to the value ofoutputChannelCount. Otherwise, the channel count of each channel in the set of output channels is set to match the corresponding value in theoutputChannelCount array.

Examples

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

Specifications

Specification
Web Audio API
# dom-audioworkletnode-audioworkletnode

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp