1ardour { 2 ["type"] = "EditorHook", 3 name = "Timed Event Example", 4 author = "Ardour Team", 5 description = "Perform actions at specific wallclock time, example record", 6} 7 8function signals () 9 return LuaSignal.Set():add ({[LuaSignal.LuaTimerDS] = true}) 10end 11 12function 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_roll (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_stop (false, false, TRS_UI); 33 end 34 35 _last_time = now 36 end 37end 38