Skip to main content

AudioSource.GetSpectrumData(number Length, number channel, FFTWindow window)

Provides a block of the currently playing audio source's spectrum data.
The array given in the samples parameter will be filled with the requested data.

Parameters:

NameTypeDescription
LengthnumberLength of the block of the Spectrum Data to be returned. Must be a power of 2.
channelnumberThe channel to sample from.
windowFFTWindowThe FFTWindow type to use when sampling.

Returns:

typeDescription
number[]The array populated with audio samples.

Usage

---@type AudioSource
local audiosource;

---@type number
local Length;

---@type number
local channel;

---@type FFTWindow
local window;


local val0 = audiosource.GetSpectrumData(Length, channel, window)

Extra Detail

Number of values (the length of the samples array provided) must be a power of 2. (ie 128/256/512 etc). Min = 64. Max = 8192. Use window to reduce leakage between frequency bins/bands. Note, the more complex window type, the better the quality, but reduced speed.