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