GetSoundProperties: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 26: Line 26:
addCommandHandler("playsound",
addCommandHandler("playsound",
function ()  
function ()  
        sound = playSound("wasted.mp3")
    sound = playSound("wasted.mp3")
timer = setTimer(function() soundProperties(sound) end, 5000, 0)
    timer = setTimer(function() soundProperties(sound) end, 5000, 0)
end
end
)
)


function soundProperties(sound)
function soundProperties(sound)
local sampleRate, tempo, pitch, isReversed = getSoundProperties(sound) --gets the sample rate, tempo, pitch and a boolean value representing whether the sound is reversed or not.
    local sampleRate, tempo, pitch, isReversed = getSoundProperties(sound) --gets the sample rate, tempo, pitch and a boolean value representing whether the sound is reversed or not.
outputChatBox(sampleRate.." "..tempo.." "..pitch.." "..tostring(isReversed))
    outputChatBox(sampleRate.." "..tempo.." "..pitch.." "..tostring(isReversed))
end
end
</syntaxhighlight>
</syntaxhighlight>

Revision as of 10:33, 18 January 2014

Accessories-text-editor.png Script Example Missing Function GetSoundProperties needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.

This function gets the properties of a specific sound.

Syntax

float, float, float, bool getSoundProperties( element sound )

Required Arguments

Returns

This function returns 3 floats and a boolean value:

The first float is the sound's sample rate, the second one the sound's tempo, and the third one the pitch of the sound. The boolean representing whether the sound is reversed or not.

Example

Click to collapse [-]
Client script

Example 1: This example would return three float values representing the sample rate, tempo, pitch and a boolean value representing whether the sound is reversed or not, every 5 seconds.

local sound 
local timer

addCommandHandler("playsound",
function () 
    sound = playSound("wasted.mp3")
    timer = setTimer(function() soundProperties(sound) end, 5000, 0)
end
)

function soundProperties(sound)
    local sampleRate, tempo, pitch, isReversed = getSoundProperties(sound) --gets the sample rate, tempo, pitch and a boolean value representing whether the sound is reversed or not.
    outputChatBox(sampleRate.." "..tempo.." "..pitch.." "..tostring(isReversed))
end

See Also