GetSoundLevelData: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Reverted edits by Ameir (talk) to last revision by Alvesvin)
Tag: Rollback
m (Change See Also template)
Line 38: Line 38:


==See Also==
==See Also==
{{Client_audio_functions}}
{{Audio_functions|client}}


[[hu:getSoundLevelData]]
[[hu:getSoundLevelData]]

Revision as of 22:14, 6 September 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

  • theSound: the sound element which level data you want to return.

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 )

Requirements

This template will be deleted.

Changelog

Version Description
1.3.2 Added player element to use a players voice

See Also