Last active
August 12, 2020 15:49
-
-
Save jean-emmanuel/5b8cbaf94fd2460db88ed5ed73bcbea3 to your computer and use it in GitHub Desktop.
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
ardour { | |
["type"] = "EditorHook", | |
name = "Automation to OSC" | |
} | |
function signals () | |
return LuaSignal.Set():add ({[LuaSignal.LuaTimerS] = true}) | |
end | |
function factory () | |
local port = ARDOUR.LuaOSC.Address ("osc.udp://127.0.0.1:5555") | |
-- define which parameters of which plugins of which track should be sent | |
local tracks = { | |
[0] = { -- [track index] = { | |
[0] = {5} -- [plugin index] = {parameters indexes} | |
}, -- } | |
[1] = { | |
[1] = {0, 2} | |
} | |
} | |
return function (signal, ref, ...) | |
-- runs every 100ms | |
local playhead = Session:transport_sample () | |
-- loop over tracks, plugins and parameters | |
for track_id, plugins in pairs(tracks) do | |
-- get route | |
local route = Session:get_remote_nth_route (track_id) | |
if not route:isnil() then | |
for plugin_id, parameters in pairs(plugins) do | |
-- get plugin | |
local plugin = route:nth_plugin (plugin_id) | |
if not plugin:isnil() then | |
for k, parameter_id in pairs(parameters) do | |
-- get AutomationList, ControlList and ParameterDescriptor | |
local al, cl, pd = ARDOUR.LuaAPI.plugin_automation (plugin, parameter_id) | |
if not cl:isnil() then | |
-- get parameter value | |
local value = cl:eval (playhead) | |
-- send osc | |
port:send("/automation", "iiif", track_id, plugin_id, parameter_id, value) | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment