AnalyserNode
The AnalyserNode
interface represents a node providing two core functionalities: extracting time-domain data and frequency-domain data from audio signals.
It is an AudioNode
that passes the audio data unchanged from input to output, but allows you to take passed data and process it.
AudioNode
properties
Number of inputs | 1 |
Number of outputs | 1 |
Channel count | 2 |
Channel count mode | max |
Channel interpretation | speakers |
Time domain vs Frequency domain
A time-domain graph illustrates how a signal evolves over time, displaying changes in amplitude or intensity as time progresses. In contrast, a frequency-domain graph reveals how the signal's energy or power is distributed across different frequency bands, highlighting the presence and strength of various frequency components over a specified range.
Constructor
BaseAudioContext.createAnalyser()
Properties
Name | Type | Description | |
---|---|---|---|
fftSize | number | Integer value representing size of Fast Fourier Transform used to determine frequency domain. In general it is size of returning time-domain data. | |
minDecibels | number | Float value representing the minimum value for the range of results from getByteFrequencyData() . | |
maxDecibels | number | Float value representing the maximum value for the range of results from getByteFrequencyData() . | |
smoothingTimeConstant | number | Float value representing averaging constant with the last analysis frame. In general the higher value the smoother is the transition between values over time. | |
window | WindowType | Enumerated value that specifies the type of window function applied when extracting frequency data. | |
frequencyBinCount | number | Integer value representing amount of the data obtained in frequency domain, half of the fftSize property. | Read only |
On Web
, the value of window
is permanently 'blackman'
, and it cannot be set like on the Android
or iOS
.
Methods
getFloatFrequencyData
The above method copies current frequency data into given array. Each value in the array represents the decibel value for a specific frequency.
Parameters | Type | Description |
---|---|---|
array | Float32Array | The array to which frequency data will be copied. |
Returns undefined
.
getByteFrequencyData
The above method copies current frequency data into given array. Each value in the array is within the range 0 to 255.
Parameters | Type | Description |
---|---|---|
array | Uint8Array | The array to which frequency data will be copied. |
Returns undefined
.
getFloatTimeDomainData
The above method copies current time-domain data into given array. Each value in the array is the magnitude of the signal at a particular time.
Parameters | Type | Description |
---|---|---|
array | Float32Array | The array to which time-domain data will be copied. |
Returns undefined
.
getByteTimeDomainData
The above method copies current time-domain data into given array. Each value in the array is within the range 0 to 255, where value of 127 indicates silence.
Parameters | Type | Description |
---|---|---|
array | Uint8Array | The array to which time-domain data will be copied. |
Returns undefined
.
Remarks
fftSize
- Default value is 2048.
- Must be a power of 2 between 32 and 32768.
- Throws
IndexSizeError
if set value is not power of 2, or is outside the allowed range.
minDecibels
- Default value is -100 dB.
- 0 dB(decibel) is the loudest possible sound, -10 dB is a 10th of that.
- When getting data from
getByteFrequencyData()
, any frequency with amplitude lower thenminDecibels
will be returned as 0. - Throws
IndexSizeError
if set value is greater than or equal tomaxDecibels
.
maxDecibels
- Default value is -30 dB.
- 0 dB(decibel) is the loudest possible sound, -10 dB is a 10th of that.
- When getting data from
getByteFrequencyData()
, any frequency with amplitude higher thenmaxDecibels
will be returned as 255. - Throws
IndexSizeError
if set value is less then or equal tominDecibels
.
smoothingTimeConstant
- Default value is 0.8.
- Nominal range is 0 to 1.
- 0 means no averaging, 1 means "overlap the previous and current buffer quite a lot while computing the value".
- Throws
IndexSizeError
if set value is outside the allowed range.
window
- Default value is
'blackman'