Skip to main content

Analyzer

Extends

Properties

PropertyModifierType
nodereadonlyAnalyserNode
frequencyBinCountreadonlynumber
fftSizepublicnumber
minDecibelspublicnumber
maxDecibelspublicnumber
smoothingTimeConstantpublicnumber

Methods

getByteTimeDomainData()

getByteTimeDomainData(buffer): void;

Copies the current waveform, or time-domain, data into a Uint8Array (unsigned byte array) passed into it.

If the array has fewer elements than the AnalyserNode.fftSize, excess elements are dropped. If it has more elements than needed, excess elements are ignored.

Parameters

ParameterTypeDescription
bufferUint8ArrayUse provided buffer instead of creating a new one

Returns

void

Remarks

The bytes versions are not cheaper than the float version but provided for convenient: the byte version are computed from the float version, using simple quantization to 2^8 values ref. https://padenot.github.io/web-audio-perf/#analysernode


getByteFrequencyData()

getByteFrequencyData(buffer): void;

Copies the current frequency data into a Uint8Array (unsigned byte array) passed into it.

The frequency data is composed of integers on a scale from 0 to 255.

Parameters

ParameterTypeDescription
bufferUint8ArrayUse provided buffer instead of creating a new one

Returns

void

Remarks

The bytes versions are not cheaper than the float version but provided for convenient: the byte version are computed from the float version, using simple quantization to 2^8 values ref. https://padenot.github.io/web-audio-perf/#analysernode


getFloatTimeDomainData()

getFloatTimeDomainData(buffer): void;

Copies the current waveform, or time-domain, data into Float32Array passed into it

Parameters

ParameterTypeDescription
bufferFloat32ArrayUse provided buffer instead of creating a new one

Returns

void

Remarks

The buffer size should be the same as AnalyserNode.fftSize


getFloatFrequencyData()

getFloatFrequencyData(buffer): void;

Copies the current waveform, or time-domain, data into Float32Array passed into it

Parameters

ParameterTypeDescription
bufferFloat32ArrayUse provided buffer instead of creating a new one

Returns

void

Remarks

The buffer size should be the same as AnalyserNode.frequencyBinCount


getAverageVolume()

getAverageVolume(buffer): number;

Utility function to get the average volume from getByteFrequencyData

Parameters

ParameterType
bufferFloat32Array

Returns

number

Remarks

This is a better option when you only need to get the volume in terms of performance and complexity.


connect()

Call Signature

connect(
destinationNode,
output?,
input?): AudioNode;

The connect() method of the AudioNode interface lets you connect one of the node's outputs to a target, which may be either another AudioNode (thereby directing the sound data to the specified node) or an AudioParam, so that the node's output data is automatically used to change the value of that parameter over time.

MDN Reference

Parameters
ParameterType
destinationNodeAudioNode
output?number
input?number
Returns

AudioNode

Inherited from
BaseAudioNode.connect

Call Signature

connect(destinationParam, output?): void;
Parameters
ParameterType
destinationParamAudioParam
output?number
Returns

void

Inherited from
BaseAudioNode.connect

disconnect()

Call Signature

disconnect(): void;

The disconnect() method of the AudioNode interface lets you disconnect one or more nodes from the node on which the method is called.

MDN Reference

Returns

void

Inherited from
BaseAudioNode.disconnect

Call Signature

disconnect(output): void;
Parameters
ParameterType
outputnumber
Returns

void

Inherited from
BaseAudioNode.disconnect

Call Signature

disconnect(destinationNode): void;
Parameters
ParameterType
destinationNodeAudioNode
Returns

void

Inherited from
BaseAudioNode.disconnect

Call Signature

disconnect(destinationNode, output): void;
Parameters
ParameterType
destinationNodeAudioNode
outputnumber
Returns

void

Inherited from
BaseAudioNode.disconnect

Call Signature

disconnect(
destinationNode,
output,
input): void;
Parameters
ParameterType
destinationNodeAudioNode
outputnumber
inputnumber
Returns

void

Inherited from
BaseAudioNode.disconnect

Call Signature

disconnect(destinationParam): void;
Parameters
ParameterType
destinationParamAudioParam
Returns

void

Inherited from
BaseAudioNode.disconnect

Call Signature

disconnect(destinationParam, output): void;
Parameters
ParameterType
destinationParamAudioParam
outputnumber
Returns

void

Inherited from
BaseAudioNode.disconnect