summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2018-03-18 15:56:06 +0100
committerRobin Gareus <robin@gareus.org>2018-03-18 15:56:28 +0100
commit20929347219355f63cb8e786e5201cd5f352d0af (patch)
tree0e0f85053dd6d4c0be6af231f595f117662965ce
parent5e2d5db6c71a7344c1a57d8daa610b18505f41dd (diff)
Example Lua script to perform action at specific wallclock time
-rw-r--r--scripts/_cron.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/_cron.lua b/scripts/_cron.lua
new file mode 100644
index 0000000000..8ec1cd797c
--- /dev/null
+++ b/scripts/_cron.lua
@@ -0,0 +1,37 @@
+ardour {
+ ["type"] = "EditorHook",
+ name = "Timed Event Example",
+ author = "Ardour Lua Task Force",
+ description = "Perform actions at specific wallclock time, example record",
+}
+
+function signals ()
+ return LuaSignal.Set():add ({[LuaSignal.LuaTimerDS] = true})
+end
+
+function factory ()
+ local _last_time = 0
+ return function (signal, ref, ...)
+
+ -- calculate seconds since midnight
+ function hhmmss (hh, mm, ss) return hh * 3600 + mm * 60 + ss end
+
+ -- current seconds since midnight UTC
+ -- (unix-time is UTC, no leap seconds, a day always has 86400 sec)
+ local now = os.time () % 86400
+
+ -- event at 09:30:00 UTC (here: rec-arm + roll)
+ if (now >= hhmmss (09, 30, 00) and _last_time < hhmmss (09, 30, 00)) then
+ Session:maybe_enable_record (false)
+ Session:request_transport_speed (1.0, true)
+ end
+
+ -- event at 09:32:00 UTC (here: rec-stop)
+ if (now >= hhmmss (09, 32, 00) and _last_time < hhmmss (09, 32, 00)) then
+ Session:disable_record (false, false)
+ Session:request_transport_speed (0.0, true)
+ end
+
+ _last_time = now
+ end
+end