-- Edit the variables below to suit your situation -- Which faders and buttons should be checked for feedback. local faders = {201, 202, 203, 204, 205, 206, 207, 208, 209} local keys = {201, 202, 203, 204, 205, 206, 207, 208, 101, 102, 103, 104, 105, 106, 107, 108, 109, 301, 302, 303, 304, 305, 306, 307, 308, 401, 402, 403, 404, 405,406, 407, 408} -- how many seconds should be between updates. -- set this higher if you have performance issues -- you can go lower for smoother feedback at your own risk local updateInterval = 0.2 -- the name of the OSC object that feedback should be sent out from local feedbackOSCName = "Feedback" -- The name of the OSC object that receives OSC data. -- This object will automatically be enabled/disabled based on desk lock state -- so locking the desk will also prevent people from messing around with your faders local inputOSCName = "ShowCockpit" -- set this to false if you don't want desk lock to disable OSC input -- this makes the "inputOSCName" variable irrelevant local disableInputWhenLocked = true -- run a full update every x amount of loops - you probably won't need to touch this local fullUpdateLoops = 10 -- No need to edit anything under this line local function sendOSC(type, id, value) local address = "/Page/" .. type .. id local cmd = 'SendOSC "' .. feedbackOSCName .. '" "' .. address .. ',f, ' .. value ..'"' Cmd(cmd) end local function buildValueStore(store, items, type) for _, item in ipairs(items) do store[#store + 1] = {id = item, type = type, value = nil} sendOSC(type, item, 0) end end local function main() breakRBloops = false local currentLockedState = false local valueStore = {} buildValueStore(valueStore, faders, "Fader") buildValueStore(valueStore, keys, "Key") local iters = 0 while not breakRBloops do iters = iters + 1 if (DeskLocked() ~= currentLockedState and disableInputWhenLocked == true) then currentLockedState = DeskLocked() local receiveOSCValue = currentLockedState and 0 or 1 Cmd('Set OSC "' .. inputOSCName .. '" "receive" ' .. receiveOSCValue) Cmd('Set OSC "' .. inputOSCName .. '" "receivecommand" ' .. receiveOSCValue) end for localExecId, storedExec in pairs(valueStore) do local endValue = storedExec["value"] local exec = GetExecutor(storedExec["id"]) if exec ~= nil then if storedExec["type"] == "Fader" then local faderValue = exec:GetFader({}) endValue = faderValue else -- exec is key endValue = 1 end else -- exec is nil endValue = nil end -- if the value has changed, send feedback over if (storedExec["value"] ~= endValue or iters == fullUpdateLoops) then local sendValue = endValue == nil and 0 or endValue sendOSC(storedExec["type"], storedExec["id"], sendValue) end valueStore[localExecId]["value"] = endValue end if iters == fullUpdateLoops then iters = 0 end coroutine.yield(updateInterval) end end return main