Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"Accurately" calculate BPM (Beats Per Minute)?

Asked by 9 years ago

I may not have much to say (and this question may be broad-ish), but can you accurately calculate BPM in RBX.lua? Doing some "deep" web search was not helpful as there were not many tutorials on calculating BPM. Whilst one site may have a tutorial, tempotap.com seems to have on what I was looking for. It works, but it is not very accurate on Lua

001--Javascript code taken from tempotap.com
002--[[
003    var startTime = null;
004        var currentBeats = 0;
005 
006 
007 
008        /*
009        $(window).keypress(function(event) {
010            var spaceBarKey = 32;
011            var lowerXKey = 120;
012            var upperXKey = 88;
013 
014            var result = true;
015 
View all 108 lines...

1 answer

Log in to vote
0
Answered by 9 years ago

(It's milliseconds, by the way)

Change line 87 to use tick instead of time -- these are two different types of time and should not be combined (tick is real time seconds, time is game seconds; game seconds can go slower than real seconds in some circumstances)

Then change line 96-99 to be:

1minutes = (now - starttime) / 60 --tick() is measured in seconds, divide by 60 seconds in a minute
2bpm = currentBeat / minutes --# beats / minutes == "beats per minute"

Notably, you were using "%" when I think you needed to use "/".

0
I thought "time()" was mostly using your pc's time (or so I read it from somewhere). This seems accurate enough. Anyways, thank you! CMVProduction 25 — 9y
Ad

Answer this question