Add the contents of globalFader.lua to your global fader. Each child fader will need the childFader.lua script and their name prefixed with the faderPrefix found in globalFader.lua The default is childFader
Created
September 18, 2022 03:34
-
-
Save mattsp1290/35123a6dbd0e6ec8c0cfb2432b159e6c to your computer and use it in GitHub Desktop.
Touch OSC Global Fader
This file contains 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
local receiveValue = 'x' | |
function onReceiveNotify(key, value) | |
if (key == 'globalFader') then | |
self.values[receiveValue] = value | |
end | |
end |
This file contains 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
local allNodes = {} | |
local childNodes = {} | |
local sendValue = 'x' | |
local faderPrefix = 'childFader' | |
function traverseTree(group) | |
local nodes = {} | |
for i=1, #group.children do | |
if group.children[i].type == ControlType.GROUP -- when a subgroup is found | |
or group.children[i].type == ControlType.PAGER then | |
local children = traverseTree(group.children[i]) -- recursion with the current subgroup | |
for j=1, #children do | |
table.insert(nodes, children[j]) | |
end | |
end | |
table.insert(nodes, group.children[i]) | |
end | |
return nodes | |
end | |
function notifyNodes(nodes) | |
for i=1, #nodes do | |
local node = nodes[i] | |
node:notify('globalFader', self.values[sendValue]) | |
end | |
end | |
function init() | |
allNodes = traverseTree(root) | |
local childCount = 0 | |
for i=1, #allNodes do | |
local node = allNodes[i] | |
if ((node.name ~= nil) and (node.name:find(faderPrefix, 1, true) == 1)) then | |
childCount = childCount + 1 | |
childNodes[childCount] = node | |
end | |
end | |
notifyNodes(childNodes) | |
end | |
function onValueChanged(key) | |
if (key == sendValue) then | |
notifyNodes(childNodes) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment