2018-03-18 10:56:06 -04:00
|
|
|
ardour {
|
|
|
|
["type"] = "EditorHook",
|
|
|
|
name = "Timed Event Example",
|
2020-09-30 16:06:35 -04:00
|
|
|
author = "Ardour Team",
|
2018-03-18 10:56:06 -04:00
|
|
|
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)
|
2019-11-26 11:02:41 -05:00
|
|
|
Session:request_transport_speed (1.0, true, ARDOUR.TransportRequestSource.TRS_UI)
|
2018-03-18 10:56:06 -04:00
|
|
|
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)
|
2019-11-26 11:02:41 -05:00
|
|
|
Session:request_transport_speed (0.0, true, ARDOUR.TransportRequestSource.TRS_UI)
|
2018-03-18 10:56:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
_last_time = now
|
|
|
|
end
|
|
|
|
end
|