-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplugin.txt
More file actions
53 lines (46 loc) · 1.54 KB
/
plugin.txt
File metadata and controls
53 lines (46 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local executor_table = {101,102,103,104,105,106,107,108,116,117,118,119,120,121,122,123,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,161,162,163,164,165,166,167,168,176,177,178,179,180,181,182,183,201,202,203,204,205,206,207,208}
local osc_config = 2
local history_fader, history_status = {}, {}
local osc_template = 'SendOSC %i "/%s%i,i,%i"'
local enabled = false
local Printf, Echo, GetExecutor, Cmd, ipairs, mfloor = Printf, Echo, GetExecutor, Cmd, ipairs, math.floor
local function send_osc(etype, exec_no, value)
-- Printf(osc_template:format(osc_config, etype, exec_no, value))
Cmd(osc_template:format(osc_config, etype, exec_no, value))
end
local function poll(exec_no)
local exec = GetExecutor(exec_no)
local value = exec and mfloor(exec:GetFader{} * 1.27) or -1
local last_value = history_fader[exec_no]
local status
if not exec then
status = -1
else
status = exec.Object and exec.Object:HasActivePlayback() and 1 or 0
end
local last_status = history_status[exec_no]
if value ~= last_value then
send_osc('Fader', exec_no, value)
history_fader[exec_no] = value
end
if status ~= last_status then
send_osc('Key', exec_no, status)
history_status[exec_no] = status
end
end
local function mainloop()
while enabled do
for _, exec_no in ipairs(executor_table) do poll(exec_no) end
coroutine.yield(0.1)
end
end
local function maintoggle()
if enabled then
enabled = false
else
enabled = true
history_fader, history_status = {}, {}
mainloop()
end
end
return maintoggle