Page tree
Skip to end of metadata
Go to start of metadata

beat2ms(beats)

Description

Function to convert a number of beats to the equivalent duration in milliseconds. One beat equals a quarter note. The current tempo is taken into account.

Available in: Processor.

Arguments

beatsThe desired duration in number of beats and fractions of it.number

Return Values

Returns the specified number of beats (quarter notes) as duration in milliseconds.

Example

-- print the position in the current bar in milliseconds
function onNote(event)
    posInBar = getBeatTimeInBar()
    if (posInBar ~= -1) then        
        posInBarMs = beat2ms(posInBar)
        print(string.format("%.3f ms", posInBarMs))
    else
        print("Playback is stopped.") 
    end
end

See Also: ms2beatms2samples, samples2ms

3 Comments

  1. I made some changes. Please read again. Thanks!