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.]]
7 ---- For use with templates: Session Template setup-hook
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.
13 -- (e.g. ~/.config/ardour5/templates/Template-Name/template.lua)
16 ---- For use as meta-session (specic session-setup scripts)
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.
23 ---- For use as meta-session (general purpose Actions)
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
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();
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" },
44 local dlg = LuaDialog.Dialog ("Template Setup", dialog_options)
46 if (not rv or rv['tracks'] == 0) then
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
54 for track in tl:iter() do
55 track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
59 Session:save_state("");