getSoundWaveData
Client
Returns the waveform of what the sound just played, for drawing oscilloscopes.
table|false getSoundWaveData(sound sound, int samples)
Parameters
| Name | Type | Description |
|---|---|---|
| sound | sound | The sound element, or a dui element for the browser's sound. |
| samples | int | How many values to return: a power of 2 from 128 to 16384. |
Returns
A table of samples values from -1 to 1, alternating left and right channel, or false if samples is not valid or the sound is paused, finished or streamed out.
Example
addEventHandler("onClientRender", root, function()
local wave = getSoundWaveData(music, 512)
if not wave then return end
for i = 0, 510, 2 do
dxDrawLine(i, 300 + wave[i] * 100, i + 2, 300 + wave[i + 2] * 100, tocolor(255, 255, 255))
end
end)NoteThe table starts at index 0.