Speed up AFL/PFL changes for large sessions
[ardour.git] / scripts / _session_test.lua
1 ardour {
2         ["type"]    = "session",
3         name        = "Good Night",
4         author      = "Ardour Lua Task Force",
5         description = [[
6         Example Ardour Session Script.
7         Session scripts are called at the beginning of every process-callback (before doing any audio processing).
8         This example stops the transport after rolling for a configurable time which can be set when instantiating the script.]]
9 }
10
11 function sess_params ()
12         return
13         {
14                 ["print"]  = { title = "Debug Print (yes/no)", default = "no", optional = true },
15                 ["time"] = { title = "Timeout (sec)", default = "90", optional = false },
16         }
17 end
18
19 function factory (params)
20         return function (n_samples)
21                 local p = params["print"] or "no"
22                 local timeout = params["time"] or 90
23                 a = a or 0
24                 if p ~= "no" then print (a, n_samples, Session:frame_rate (), Session:transport_rolling ()) end -- debug output (not rt safe)
25                 if (not Session:transport_rolling()) then
26                         a = 0
27                         return
28                 end
29                 a = a + n_samples
30                 if (a > timeout * Session:frame_rate()) then
31                         Session:request_transport_speed(0.0, true)
32                 end
33         end
34 end