GetSoundBPM: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (Removed breakline.)
Line 3: Line 3:
{{New feature/item|3.0131|1.3.0|4145|
{{New feature/item|3.0131|1.3.0|4145|
This function gets the beats per minute of a specific [[sound]] element.
This function gets the beats per minute of a specific [[sound]] element.
{{Warning|This function is expensive to call and will freeze the client about 1-3 seconds. Also, trying to get the BPM from a sound directly after creation will not work. You need a
{{Warning|This function is expensive to call and will freeze the client about 1-3 seconds. Also, trying to get the BPM from a sound directly after creation will not work. You need a [[setTimer]] to do this.}}
[[setTimer]] to do this.}}
}}
}}



Revision as of 19:48, 18 August 2021

This function gets the beats per minute of a specific sound element.

[[|link=|]] Warning: This function is expensive to call and will freeze the client about 1-3 seconds. Also, trying to get the BPM from a sound directly after creation will not work. You need a setTimer to do this.

Syntax

int getSoundBPM ( element sound )

OOP Syntax Help! I don't understand this!

Method: sound:getBPM(...)


Required Arguments

Returns

Returns the beats per minute of the given sound.

Example

Click to collapse [-]
Client
function bpm ()
    -- Long version (might be more understandable as example)
    sound = playSound ( "song.mp3" ) -- Play the song
    beats = getSoundBPM ( sound ) -- Get the beats per minute of the song
    outputChatBox ( "Long code version: " .. beats ) -- Output the beats to the chat box
end
addCommandHandler ( "bpm", bpm )

Requirements

This template will be deleted.

See Also