prefix blessed scripted DSP plugins with a-*
[ardour.git] / scripts / hook_test.lua
1 ardour {
2         ["type"]    = "EditorHook",
3         name        = "Callback Example",
4         author      = "Ardour Lua Task Force",
5         description = "Rewind On Solo Change, Write a file when regions are moved",
6 }
7
8 function signals ()
9         s = LuaSignal.Set()
10         --s:add ({[LuaSignal.SoloActive] = true, [LuaSignal.RegionPropertyChanged] = true})
11         s:add (
12                 {
13                         [LuaSignal.SoloActive] = true,
14                         [LuaSignal.RegionPropertyChanged] = true
15                 }
16         )
17         --for k,v in pairs (s:table()) do print (k, v) end
18         return s
19 end
20
21 function factory (params)
22         return function (signal, ref, ...)
23                 print (signal, ref, ...)
24
25                 if (signal == LuaSignal.SoloActive) then
26                         Session:goto_start()
27                 end
28
29                 if (signal == LuaSignal.RegionPropertyChanged) then
30                         obj,pch = ...
31                         file = io.open ("/tmp/test" ,"a")
32                         io.output (file)
33                         io.write (string.format ("Region: '%s' pos-changed: %s, length-changed: %s\n",
34                                 obj:name (),
35                                 tostring (pch:containsFramePos (ARDOUR.Properties.Start)),
36                                 tostring (pch:containsFramePos (ARDOUR.Properties.Length))
37                                 ))
38                         io.close (file)
39                 end
40         end
41 end