updated naming, hooking mechanism and efficientcy
Signed-off-by: Ebbe Baß <ebbe.bass>
This commit is contained in:
+5989
File diff suppressed because it is too large
Load Diff
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GMA3 DataVersion="2.0.2.0">
|
||||
<UserPlugin Name="MA3 OSC FEEDBACK" Guid="E3 1C 05 FC 18 8A 10 00 0D 45 18 A2 5E 43 E6 27" Version="1.0.0.0">
|
||||
<ComponentLua Name="MA3 OSC FEEDBACK" Guid="37 F3 0C 07 C5 0C 10 02 B2 2C 1E 4D F2 1C 2D A1" FileName="MA3 OSC FEEDBACK.lua" />
|
||||
</UserPlugin>
|
||||
</GMA3>
|
||||
@@ -2,6 +2,10 @@
|
||||
-- I will not take any responsibility if something breaks at any time. I consider this plugin as unstable.
|
||||
-- To this date (10.08.2024) I've never had problems with it, but still I am going to consider it as unstable.
|
||||
|
||||
local osc_config = 1
|
||||
local osc_template = 'SendOSC %i "/%s%i,i,%i"'
|
||||
local osc_str_template = 'SendOSC %i "/%s%i,s,%s"'
|
||||
local debug = false
|
||||
local executor_table = {
|
||||
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
|
||||
201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
|
||||
@@ -10,12 +14,6 @@ local executor_table = {
|
||||
291, 292, 293, 294, 295, 296, 297, 298,
|
||||
191, 192, 193, 194, 195, 196, 197, 198
|
||||
}
|
||||
local osc_config = 1
|
||||
local osc_template = 'SendOSC %i "/%s%i,i,%i"'
|
||||
local osc_str_template = 'SendOSC %i "/%s%i,s,%s"'
|
||||
local enabled = false
|
||||
local Printf, Echo, GetExecutor, Cmd, ipairs, mfloor = Printf, Echo, GetExecutor, Cmd, ipairs, math.floor
|
||||
local debug = true
|
||||
|
||||
local color_map = {
|
||||
Sequence = {166, 125, 0},
|
||||
@@ -33,20 +31,28 @@ local color_map = {
|
||||
Timer = {103, 103, 110}
|
||||
}
|
||||
|
||||
local function debug_print(msg)
|
||||
function debug_print(msg)
|
||||
if debug then
|
||||
Printf(msg)
|
||||
end
|
||||
end
|
||||
|
||||
local function send_osc(etype, exec_no, value)
|
||||
local function tablelength(T)
|
||||
local count = 0
|
||||
for _ in pairs(T) do
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
function send_osc(etype, exec_no, value)
|
||||
local cmd_str = osc_template:format(osc_config, etype, exec_no, value)
|
||||
debug_print(cmd_str)
|
||||
Cmd(cmd_str)
|
||||
end
|
||||
|
||||
-- Function to reset all button LEDs to off (set RGB to 0)
|
||||
local function reset_all_leds()
|
||||
function reset_all_leds()
|
||||
for _, exec_no in ipairs(executor_table) do
|
||||
send_osc("ExecCol_R", exec_no, 0)
|
||||
send_osc("ExecCol_G", exec_no, 0)
|
||||
@@ -61,8 +67,8 @@ local function reset_all_leds()
|
||||
end
|
||||
|
||||
-- Reuse function to handle empty playback
|
||||
local function handle_empty_playback(exec_no)
|
||||
debug_print('Empty playback found on:'..tostring(exec_no))
|
||||
function handle_empty_playback(exec_no)
|
||||
debug_print('Empty playback found on:' .. tostring(exec_no))
|
||||
if (exec_no >= 291 and exec_no <= 298) or (exec_no >= 191 and exec_no <= 198) then
|
||||
Cmd(osc_str_template:format(osc_config, "xKey", exec_no, ""))
|
||||
end
|
||||
@@ -71,7 +77,7 @@ local function handle_empty_playback(exec_no)
|
||||
send_osc("ExecCol_B", exec_no, 0)
|
||||
end
|
||||
|
||||
local function poll(exec_no)
|
||||
function poll(exec_no)
|
||||
local exec = GetExecutor(exec_no)
|
||||
local execAssObjNoClass = exec and exec:GetAssignedObj()
|
||||
|
||||
@@ -112,25 +118,24 @@ local function poll(exec_no)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function mainloop()
|
||||
while enabled do
|
||||
for _, exec_no in ipairs(executor_table) do
|
||||
poll(exec_no)
|
||||
end
|
||||
coroutine.yield(0.05)
|
||||
function callback()
|
||||
for i=1, tablelength(executor_table) do
|
||||
poll(executor_table[i])
|
||||
end
|
||||
debug_print("Updated")
|
||||
end
|
||||
|
||||
local function maintoggle()
|
||||
if enabled then
|
||||
enabled = false
|
||||
else
|
||||
enabled = true
|
||||
-- Reset all LEDs to off before starting the main loop
|
||||
-- Get the handle to this Lua component.
|
||||
local luaComponentHandle = select(4,...)
|
||||
|
||||
function main()
|
||||
reset_all_leds()
|
||||
mainloop()
|
||||
end
|
||||
-- Setup hooks for all executors
|
||||
local pluginHandle = luaComponentHandle:Parent()
|
||||
|
||||
local hookedObj = DataPool().Pages
|
||||
HookObjectChange(callback, hookedObj, pluginHandle)
|
||||
debug_print("Hooking changes to executors.")
|
||||
end
|
||||
|
||||
return maintoggle
|
||||
return main
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GMA3 DataVersion="2.0.2.0">
|
||||
<UserPlugin Name="OSC feedback" Guid="01 33 F7 3E 05 35 46 5F AE 33 44 0F 11 88 3E DC" Version="2.0.2.0">
|
||||
<ComponentLua Name="OSC feedback" Guid="27 D8 BC 18 5C 58 45 54 9F 7F EA F9 B8 28 8D 5D" FileName="OSC feedback.lua" />
|
||||
</UserPlugin>
|
||||
</GMA3>
|
||||
Reference in New Issue
Block a user