diff options
author | Robin Gareus <robin@gareus.org> | 2016-03-19 13:15:37 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-03-19 13:15:37 +0100 |
commit | 93449d3431d775d316632eb6c7d15cf4665a8d13 (patch) | |
tree | 0f8501978239e22aa29fe7dc8813caa9aefe5118 /scripts | |
parent | d0746b8378689268c0fc09e7c9155282ae6c7c38 (diff) |
expose Lua OSC transmitter
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/osc_hook_example.lua | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/osc_hook_example.lua b/scripts/osc_hook_example.lua new file mode 100644 index 0000000000..c204ed9a8e --- /dev/null +++ b/scripts/osc_hook_example.lua @@ -0,0 +1,51 @@ +ardour { + ["type"] = "EditorHook", + name = "OSC Callback Example", + 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.RegionPropertyChanged] = true, + [LuaSignal.Exported] = true, + [LuaSignal.TransportStateChange] = true + } + ) + return s +end + +function factory (params) + return function (signal, ref, ...) + local uri = params["unique"] or "osc.udp://localhost:7890" + local tx = OSC.Address (uri) + -- 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_frame(), Session:transport_speed()) + elseif (signal == LuaSignal.RegionPropertyChanged) then + obj,pch = ... + tx:send ("/region_property_changed", "sTTiii", + obj:name (), + (pch:containsFramePos (ARDOUR.Properties.Start)), + (pch:containsFramePos (ARDOUR.Properties.Length)), + obj:position (), obj:start (), obj:length ()) + end + end +end |