Optimize automation-event process splitting
[ardour.git] / scripts / _osc_hook_example.lua
1 ardour {
2         ["type"]    = "EditorHook",
3         name        = "OSC Callback Example",
4         author      = "Ardour Lua Task Force",
5         description = "Send OSC messages",
6 }
7
8 function action_params ()
9         return
10         {
11                 ["uri"] = { title = "OSC URI ", default = "osc.udp://localhost:7890"},
12         }
13 end
14
15
16 function signals ()
17         s = LuaSignal.Set()
18         s:add (
19                 {
20                         [LuaSignal.SoloActive] = true,
21                         [LuaSignal.RegionPropertyChanged] = true,
22                         [LuaSignal.Exported] = true,
23                         [LuaSignal.TransportStateChange] = true
24                 }
25         )
26         return s
27 end
28
29 function factory (params)
30         return function (signal, ref, ...)
31                 local uri = params["unique"] or "osc.udp://localhost:7890"
32                 local tx = ARDOUR.LuaOSC.Address (uri)
33                 -- debug print (stdout)
34                 -- print (signal, ref, ...)
35
36                 if (signal == LuaSignal.Exported) then
37                         tx:send ("/session/exported", "ss", ...)
38                 elseif (signal == LuaSignal.SoloActive) then
39                         tx:send ("/session/solo_changed", "")
40                 elseif (signal == LuaSignal.TransportStateChange) then
41                         tx:send ("/session/transport", "if",
42                                 Session:transport_sample(), Session:transport_speed())
43                 elseif (signal == LuaSignal.RegionPropertyChanged) then
44                         obj,pch = ...
45                         tx:send ("/region_property_changed", "sTTiii",
46                                 obj:name (),
47                                 (pch:containsFramePos (ARDOUR.Properties.Start)),
48                                 (pch:containsFramePos (ARDOUR.Properties.Length)),
49                                 obj:position (), obj:start (), obj:length ())
50                 end
51         end
52 end