fix mistaken "do not roll" conclusion in TransportFSM::compute_should_roll()
[ardour.git] / scripts / session_template_record.lua
1 ardour {
2         ["type"]    = "SessionInit",
3         name        = "Recording Session",
4         description = [[Add as many mono tracks to the new session as there are physical audio inputs and optionally record-arm them.]]
5 }
6
7 ---- For use with templates: Session Template setup-hook
8 --
9 -- If a script named 'template.lua' exists in a session-template folder
10 -- the function produced by the 'factory' function of the script is called
11 -- once after creating the session from the template.
12 --
13 -- (e.g. ~/.config/ardour5/templates/Template-Name/template.lua)
14 --
15 --
16 ---- For use as meta-session (specic session-setup scripts)
17 --
18 -- Every Lua script in the script-folder of type "SessionInit"
19 -- is listed as implicit template in the new-session dialog.
20 -- The function produced by the scripts `factory` function is called
21 -- once after creating a new, empty session.
22 --
23 ---- For use as meta-session (general purpose Actions)
24 --
25 -- In some cases normal action scripts can also serve as session-setup
26 -- To include those ActionScripts in the template-list the script needs
27 -- to implement an additional function
28 --      function session_setup () return true end;
29 -- The script's factory will be called without any parameters
30
31 function factory () return function ()
32         local e = Session:engine()
33         -- from the engine's POV readable/capture ports are "outputs"
34         local _, t = e:get_backend_ports ("", ARDOUR.DataType("audio"), ARDOUR.PortFlags.IsOutput | ARDOUR.PortFlags.IsPhysical, C.StringVector())
35         -- table 't' holds argument references. t[4] is the C.StringVector (return value)
36         local tracks = t[4]:size();
37
38         local dialog_options = {
39                 { type = "heading", title = "Customize Session: " .. Session:name () },
40                 { type = "number", key = "tracks", title = "Create Tracks",  min = 1, max = 128, step = 1, digits = 0, default = tracks },
41                 { type = "checkbox", key = "recarm", default = false, title = "Record Arm Tracks" },
42         }
43
44         local dlg = LuaDialog.Dialog ("Template Setup", dialog_options)
45         local rv = dlg:run()
46         if (not rv or rv['tracks'] == 0) then
47                 return
48         end
49
50         -- create tracks
51         local tl = Session:new_audio_track (1, 2, nil, rv['tracks'], "",  ARDOUR.PresentationInfo.max_order, ARDOUR.TrackMode.Normal)
52         -- and optionally record-arm them
53         if rv['recarm'] then
54                 for track in tl:iter() do
55                         track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
56                 end
57         end
58
59         Session:save_state("");
60 end end