OSC: fix issue #7444 send fader position/gain even when 0.
[ardour.git] / scripts / _template_example.lua
1 --
2 -- Session Template setup-hook
3 --
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.
7 --
8 -- (e.g. ~/.config/ardour5/templates/Template-Name/template.lua
9 --
10
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();
17
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" },
22         }
23
24         local dlg = LuaDialog.Dialog ("Template Setup", dialog_options)
25         local rv = dlg:run()
26         if (not rv or rv['tracks'] == 0) then
27                 return
28         end
29
30         -- create tracks
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
33         if rv['recarm'] then
34                 for track in tl:iter() do
35                         track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
36                 end
37         end
38
39         Session:save_state("");
40 end