fix mistaken "do not roll" conclusion in TransportFSM::compute_should_roll()
[ardour.git] / scripts / _cron.lua
1 ardour {
2         ["type"]    = "EditorHook",
3         name        = "Timed Event Example",
4         author      = "Ardour Lua Task Force",
5         description = "Perform actions at specific wallclock time, example record",
6 }
7
8 function signals ()
9         return LuaSignal.Set():add ({[LuaSignal.LuaTimerDS] = true})
10 end
11
12 function factory ()
13         local _last_time = 0
14         return function (signal, ref, ...)
15
16                 -- calculate seconds since midnight
17                 function hhmmss (hh, mm, ss) return hh * 3600 + mm * 60 + ss end
18
19                 -- current seconds since midnight UTC
20                 -- (unix-time is UTC, no leap seconds, a day always has 86400 sec)
21                 local now = os.time () % 86400
22
23                 -- event at 09:30:00 UTC (here: rec-arm + roll)
24                 if (now >= hhmmss (09, 30, 00) and _last_time < hhmmss (09, 30, 00)) then
25                         Session:maybe_enable_record (false)
26                         Session:request_transport_speed (1.0, true,  ARDOUR.TransportRequestSource.TRS_UI)
27                 end
28
29                 -- event at 09:32:00 UTC (here: rec-stop)
30                 if (now >= hhmmss (09, 32, 00) and _last_time < hhmmss (09, 32, 00)) then
31                         Session:disable_record (false, false)
32                         Session:request_transport_speed (0.0, true, ARDOUR.TransportRequestSource.TRS_UI)
33                 end
34
35                 _last_time = now
36         end
37 end