getSoundWaveData
Client-side
Server-side
Shared
This function gets the wave form data for an audio stream which is a table of floats representing the current audio frame as a wave. This allows things like visualisations.
If the element is a player, this function will use the player's voice.
OOP Syntax Help! I don't understand this!
- Method:sound:getWaveData(...)
Syntax
table|false getSoundWaveData ( sound/player theSound, int samples )Required arguments
- theSound: A sound element that is created using playSound or playSound3D. Streams are also supported
- samples: Allowed samples are 256, 512, 1024, 2048, 4096, 8192 and 16384.
Returns
Returns a table of samples floats representing the current audio frame waveform. Returns false if the sound is not playing yet or hasn't buffered in the case of streams.
- table|false: wave-data
Code Examples
client
This example creates a sound visualizer on the top left corner of the screen.
local soundHandler = playSound("sound.wav")
function onSoundPlayRender() if (soundHandler) then local waveData = getSoundWaveData(soundHandler, 256) if (waveData) then for i = 0, 255 do dxDrawRectangle(i, 128, 1, waveData[i] * 128) end end endendaddEventHandler("onClientRender", getRootElement(), onSoundPlayRender)Changelog
Added player element to use a players voice.
See Also
Audio Functions
- getRadioChannel
- getRadioChannelName
- getSFXStatus
- getSoundBPM
- getSoundBufferLength
- getSoundEffectParameters
- getSoundEffects
- getSoundFFTData
- getSoundLength
- getSoundLevelData
- getSoundMaxDistance
- getSoundMetaTags
- getSoundMinDistance
- getSoundPan
- getSoundPosition
- getSoundProperties
- getSoundSpeed
- getSoundVolume
- getSoundWaveData
- isSoundLooped
- isSoundPanningEnabled
- isSoundPaused
- playSFX
- playSFX3D
- playSound
- playSound3D
- playSoundFrontEnd
- setRadioChannel
- setSoundEffectEnabled
- setSoundEffectParameter
- setSoundLooped
- setSoundMaxDistance
- setSoundMinDistance
- setSoundPan
- setSoundPanningEnabled
- setSoundPaused
- setSoundPosition
- setSoundProperties
- setSoundSpeed
- setSoundVolume
- stopSound