expose Lua OSC transmitter
authorRobin Gareus <robin@gareus.org>
Sat, 19 Mar 2016 12:15:37 +0000 (13:15 +0100)
committerRobin Gareus <robin@gareus.org>
Sat, 19 Mar 2016 12:15:37 +0000 (13:15 +0100)
gtk2_ardour/luainstance.cc
scripts/osc_hook_example.lua [new file with mode: 0644]

index 8e86a9bb52038a1e83160045a6b486f3593b6b92..70d88cdf5f08602f9a193dfe3f6446eb15cbe49c 100644 (file)
@@ -193,6 +193,7 @@ LuaInstance::register_classes (lua_State* L)
        LuaBindings::stddef (L);
        LuaBindings::common (L);
        LuaBindings::session (L);
+       LuaBindings::osc (L);
 
        bind_cairo (L);
        register_hooks (L);
diff --git a/scripts/osc_hook_example.lua b/scripts/osc_hook_example.lua
new file mode 100644 (file)
index 0000000..c204ed9
--- /dev/null
@@ -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