W3cubDocs

/Web APIs

ScriptProcessorNode

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

The ScriptProcessorNode interface allows the generation, processing, or analyzing of audio using JavaScript.

EventTarget AudioNode ScriptProcessorNode

Note: This feature was replaced by AudioWorklets and the AudioWorkletNode interface.

The ScriptProcessorNode interface is an AudioNode audio-processing module that is linked to two buffers, one containing the input audio data, one containing the processed output audio data. An event, implementing the AudioProcessingEvent interface, is sent to the object each time the input buffer contains new data, and the event handler terminates when it has filled the output buffer with data.

The ScriptProcessorNode stores the input in a buffer, send the audioprocess event. The EventHandler takes the input buffer and fill the output buffer which is sent to the output by the ScriptProcessorNode.

The size of the input and output buffer are defined at the creation time, when the BaseAudioContext.createScriptProcessor method is called (both are defined by BaseAudioContext.createScriptProcessor's bufferSize parameter). The buffer size must be a power of 2 between 256 and 16384, that is 256, 512, 1024, 2048, 4096, 8192 or 16384. Small numbers lower the latency, but large number may be necessary to avoid audio breakup and glitches.

If the buffer size is not defined, which is recommended, the browser will pick one that its heuristic deems appropriate.

Number of inputs 1
Number of outputs 1
Channel count mode "max"
Channel count 2 (not used in the default count mode)
Channel interpretation "speakers"

Instance properties

Inherits properties from its parent, AudioNode.

ScriptProcessorNode.bufferSize Read only Deprecated

Returns an integer representing both the input and output buffer size. Its value can be a power of 2 value in the range 25616384.

Instance methods

No specific methods; inherits methods from its parent, AudioNode.

Events

Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface:

audioprocess Deprecated

Fired when an input buffer of a ScriptProcessorNode is ready to be processed. Also available via the onaudioprocess event handler property.

Examples

Specifications

Since the August 29, 2014 Web Audio API specification publication, this feature has been deprecated. It is no longer on track to become a standard.

It was replaced by AudioWorklets and the AudioWorkletNode interface.

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
ScriptProcessorNode 24 12 25 No 15 7 ≤37 25 25 14 7 1.5
audioprocess_event 24 12 25 No 15 7 ≤37 25 25 14 7 1.5
bufferSize 24 12 25 No 15 7 ≤37 25 25 14 7 1.5

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ScriptProcessorNode