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