exercise new lua bindings
[ardour.git] / scripts / session_test.lua
1 ardour {
2         ["type"]    = "session",
3         name        = "Example",
4         license     = "MIT",
5         author      = "Robin Gareus",
6         email       = "robin@gareus.org",
7         site        = "http://gareus.org",
8         description = [[
9         An Example Ardour Session Process Plugin.
10         Install a 'hook' that is called on every process cycle
11         (before doing any processing).
12         This example stops the transport after rolling for a specific time.]]
13 }
14
15 function sess_params ()
16         return
17         {
18                 ["print"]  = { title = "Debug Print (yes/no)", default = "no", optional = true },
19                 ["time"] = { title = "Timeout (sec)", default = "90", optional = false },
20         }
21 end
22
23 function factory (params)
24         return function (n_samples)
25                 local p = params["print"] or "no"
26                 local timeout = params["time"] or 90
27                 a = a or 0
28                 if p ~= "no" then print (a, n_samples, Session:frame_rate (), Session:transport_rolling ()) end -- debug output (not rt safe)
29                 if (not Session:transport_rolling()) then
30                         a = 0
31                         return
32                 end
33                 a = a + n_samples
34                 if (a > timeout * Session:frame_rate()) then
35                         Session:request_transport_speed(0.0, true)
36                 end
37         end
38 end