13
0
livetrax/share/scripts/_osc_hook_example.lua

55 lines
1.4 KiB
Lua
Raw Normal View History

2016-03-19 08:15:37 -04:00
ardour {
["type"] = "EditorHook",
name = "OSC Callback Example",
2020-09-30 16:06:35 -04:00
author = "Ardour Team",
2016-03-19 08:15:37 -04:00
description = "Send OSC messages",
}
function action_params ()
return
{
["uri"] = { title = "OSC URI ", default = "osc.udp://localhost:7890"},
}
end
function signals ()
s = LuaSignal.Set()
s:add (
{
[LuaSignal.SoloActive] = true,
[LuaSignal.RegionsPropertyChanged] = true,
2016-03-19 08:15:37 -04:00
[LuaSignal.Exported] = true,
[LuaSignal.TransportStateChange] = true
}
)
return s
end
function factory (params)
return function (signal, ref, ...)
2019-04-07 16:48:56 -04:00
local uri = params["uri"] or "osc.udp://localhost:7890"
2016-03-26 09:54:45 -04:00
local tx = ARDOUR.LuaOSC.Address (uri)
2016-03-19 08:15:37 -04:00
-- debug print (stdout)
-- print (signal, ref, ...)
if (signal == LuaSignal.Exported) then
tx:send ("/session/exported", "ss", ...)
elseif (signal == LuaSignal.SoloActive) then
tx:send ("/session/solo_changed", "")
elseif (signal == LuaSignal.TransportStateChange) then
tx:send ("/session/transport", "if",
Session:transport_sample(), Session:transport_speed())
elseif (signal == LuaSignal.RegionsPropertyChanged) then
rl,pch = ...
for region in rl:iter() do
tx:send ("/region_property_changed", "sTTiii",
region:name (),
2022-09-27 12:58:53 -04:00
(pch:containsTimePos (ARDOUR.Properties.Start)),
(pch:containsTimeCnt (ARDOUR.Properties.Length)),
region:position ():samples(), region:start ():samples(), region:length ():samples())
end
2016-03-19 08:15:37 -04:00
end
end
end