GetSoundLevelData: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(11 intermediate revisions by 9 users not shown) | |||
Line 7: | Line 7: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">int, int getSoundLevelData ( element theSound )</syntaxhighlight> | <syntaxhighlight lang="lua">int, int getSoundLevelData ( element theSound )</syntaxhighlight> | ||
{{OOP||[[sound]]:getLevelData}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theSound:''' the [[sound]] [[element]] which level data you want to return. | *'''theSound:''' the [[sound]] [[element]] which level data you want to return. | ||
===Returns=== | ===Returns=== | ||
Returns a | Returns a two ''integers'' in range from 0 to 32768. | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local | local soundHandler = playSound ( "sound.wav" ) | ||
function | function onSoundPlayRender ( ) | ||
if( | if ( soundHandler ) then | ||
local leftData, rightData = getSoundLevelData ( soundHandler ) | |||
if ( leftData ) then | |||
dxDrawRectangle ( 0, 0, 64, leftData / 32768 * 256, tocolor ( 255, 0, 0 ) ) | |||
dxDrawRectangle ( 64, 0, 64, rightData / 32768 * 256, tocolor ( 0, 0, 255 ) ) | |||
end | |||
end | end | ||
end | end | ||
addEventHandler ( "onClientRender", root, onSoundPlayRender ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==Changelog== | ==Changelog== | ||
Line 68: | Line 35: | ||
==See Also== | ==See Also== | ||
{{ | {{Audio_functions|client}} | ||
[[hu:getSoundLevelData]] | |||
[[ar:getSoundLevelData]] | [[ar:getSoundLevelData]] | ||
[[ro:getSoundLevelData]] | |||
[[pt-br:getSoundLevelData]] |
Latest revision as of 17:07, 7 November 2024
This function gets the left/right level from a sound element. If the element is a player, this function will use the players voice.
Syntax
int, int getSoundLevelData ( element theSound )
OOP Syntax Help! I don't understand this!
- Method: sound:getLevelData(...)
Required Arguments
Returns
Returns a two integers in range from 0 to 32768.
Example
local soundHandler = playSound ( "sound.wav" ) function onSoundPlayRender ( ) if ( soundHandler ) then local leftData, rightData = getSoundLevelData ( soundHandler ) if ( leftData ) then dxDrawRectangle ( 0, 0, 64, leftData / 32768 * 256, tocolor ( 255, 0, 0 ) ) dxDrawRectangle ( 64, 0, 64, rightData / 32768 * 256, tocolor ( 0, 0, 255 ) ) end end end addEventHandler ( "onClientRender", root, onSoundPlayRender )
Changelog
Version | Description |
---|
1.3.2 | Added player element to use a players voice |
See Also
- getRadioChannel
- getRadioChannelName
- getSFXStatus
- getSoundBPM
- getSoundBufferLength
- getSoundEffectParameters
- getSoundEffects
- getSoundFFTData
- getSoundLength
- getSoundLevelData
- getSoundMaxDistance
- getSoundMetaTags
- getSoundMinDistance
- getSoundPan
- getSoundPosition
- getSoundProperties
- getSoundSpeed
- getSoundVolume
- getSoundWaveData
- isSoundLooped
- isSoundPanningEnabled
- isSoundPaused
- playSFX3D
- playSFX
- playSound3D
- playSound
- setRadioChannel
- setSoundEffectEnabled
- setSoundEffectParameter
- setSoundLooped
- setSoundMaxDistance
- setSoundMinDistance
- setSoundPan
- setSoundPanningEnabled
- setSoundPaused
- setSoundPosition
- setSoundProperties
- setSoundSpeed
- setSoundVolume
- stopSound
- Shared
- playSoundFrontEnd