GetSoundBPM: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Warning about performance)
Line 24: Line 24:
     beats = getSoundBPM ( sound ) -- Get the beats per minute of 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
     outputChatBox ( "Long code version: " .. beats ) -- Output the beats to the chat box
    -- Short version + Would save some memory
    outputChatBox ( "Short code version: " .. getSoundBPM ( playSound ( "song.mp3" ) ) )
end
end
addCommandHandler ( "bpm", bpm )
addCommandHandler ( "bpm", bpm )

Revision as of 00:14, 21 January 2020

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