summaryrefslogtreecommitdiff
path: root/scripts/hook_test.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/hook_test.lua')
-rw-r--r--scripts/hook_test.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/hook_test.lua b/scripts/hook_test.lua
new file mode 100644
index 0000000000..a4676c5135
--- /dev/null
+++ b/scripts/hook_test.lua
@@ -0,0 +1,40 @@
+ardour {
+ ["type"] = "EditorHook",
+ name = "Callback Example",
+ description = "Rewind On Solo Change, Write a file when regions are moved",
+}
+
+function signals ()
+ s = LuaSignal.Set()
+ --s:add ({[LuaSignal.SoloActive] = true, [LuaSignal.RegionPropertyChanged] = true})
+ s:add (
+ {
+ [LuaSignal.SoloActive] = true,
+ [LuaSignal.RegionPropertyChanged] = true
+ }
+ )
+ --for k,v in pairs (s:table()) do print (k, v) end
+ return s
+end
+
+function factory (params)
+ return function (signal, ref, ...)
+ print (signal, ref, ...)
+
+ if (signal == LuaSignal.SoloActive) then
+ Session:goto_start()
+ end
+
+ if (signal == LuaSignal.RegionPropertyChanged) then
+ obj,pch = ...
+ file = io.open ("/tmp/test" ,"a")
+ io.output (file)
+ io.write (string.format ("Region: '%s' pos-changed: %s, length-changed: %s\n",
+ obj:name (),
+ tostring (pch:containsFramePos (ARDOUR.Properties.Start)),
+ tostring (pch:containsFramePos (ARDOUR.Properties.Length))
+ ))
+ io.close (file)
+ end
+ end
+end