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