Created
January 27, 2021 14:12
-
-
Save xuio/3328788332f8c38864b07234723dc5bd to your computer and use it in GitHub Desktop.
MA2 Speedmaster to Resolume
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arena = GetElement('Arena') | |
ma2 = GetElement('onpc_main') | |
--set rate/speedmaster executor number (you should fix it in ma) | |
exec_speedmaster = 1 | |
exec_ratemaster = 2 | |
function map(x, out_min, out_max) | |
return (x - out_min) / (out_max - out_min) | |
end | |
once = false | |
function logonce(msg) | |
if not once then | |
once = true | |
LogWarning(msg) | |
end | |
end | |
function getBPM() | |
-- get SpeedMaster Value | |
local sm = ma2.GetExecutorCurrentCue(exec_speedmaster) | |
-- gma2 not yet available | |
if sm == nil then | |
logonce('GMA2 not online') | |
sleep(10) | |
return -1; | |
end | |
-- remove " BPM" | |
sm = string.gsub(sm, " BPM", "") | |
-- get RateMaster value | |
local rm = ma2.GetExecutorCurrentCue(exec_ratemaster) | |
-- transform default value | |
if rm == "1:1" then | |
rm = "1.0" | |
end | |
-- cast to number | |
sm = tonumber(sm) | |
rm = tonumber(rm) | |
return (sm*rm) | |
end | |
function setResBpm(bpm) | |
local bpm_res = map(bpm, 20, 500) | |
-- send to resolume ... somehow the range is offset by -2 bpm | |
arena.BPMFader_FaderMove(2, 500, bpm_res) | |
end | |
lastBpm = -1 | |
while true do | |
-- get BPM from MA2 | |
bpm = getBPM() | |
-- did it change? | |
if bpm ~= lastBpm then | |
setResBpm(bpm) | |
lastBpm = bpm | |
LogInformation('Set Resolume BPM to ' .. bpm); | |
end | |
sleep(0.1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment