2 -- Session Template setup-hook
4 -- If a script named 'template.lua' exists in a session-template folder
5 -- the `template_load` function of the script is called after
6 -- creating the session from the template.
8 -- (e.g. ~/.config/ardour5/templates/Template-Name/template.lua
11 function template_load ()
12 local e = Session:engine()
13 -- from the engine's POV readable/capture ports are "outputs"
14 local _, t = e:get_backend_ports ("", ARDOUR.DataType("audio"), ARDOUR.PortFlags.IsOutput | ARDOUR.PortFlags.IsPhysical, C.StringVector())
15 -- table 't' holds argument references. t[4] is the C.StringVector (return value)
16 local tracks = t[4]:size();
18 local dialog_options = {
19 { type = "heading", title = "Customize Session: " .. Session:name () },
20 { type = "number", key = "tracks", title = "Create Tracks", min = 0, max = 128, step = 1, digits = 0, default = tracks },
21 { type = "checkbox", key = "recarm", default = false, title = "Record Arm Tracks" },
24 local dlg = LuaDialog.Dialog ("Template Setup", dialog_options)
26 if (not rv or rv['tracks'] == 0) then
31 local tl = Session:new_audio_track (1, 2, nil, rv['tracks'], "", ARDOUR.PresentationInfo.max_order, ARDOUR.TrackMode.Normal)
32 -- and optionally record-arm them
34 for track in tl:iter() do
35 track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
39 Session:save_state("");