ccfb26d7c633c3523e2e180fd03d9adb40c2882f
[ardour.git] / scripts / _template_band.lua
1 ardour {
2         ["type"]    = "SessionInit",
3         name        = "Live Band Recording Session",
4         description = [[
5 This template helps create the tracks for a typical pop/rock band.
6
7 You will be prompted to assemble your session from a list of track types.
8
9 Each track comes with its pre-assigned grouping, routing, EQ and plugins.
10 ]]
11 }
12
13 function factory () return function ()
14
15         --prompt the user for the tracks they'd like to instantiate
16         local dialog_options = {
17                 { type = "heading", title = "Select the tracks you'd like\n to add to your session: " },
18
19                 { type = "checkbox", key = "LeadVox", default = false, title = "Lead Vocal" },
20
21                 { type = "checkbox", key = "Bass", default = false, title = "Bass" },
22
23                 { type = "checkbox", key = "Piano", default = false, title = "Piano" },
24                 { type = "checkbox", key = "E. Piano", default = false, title = "E. Piano" },
25                 { type = "checkbox", key = "Organ", default = false, title = "Organ" },
26
27                 { type = "checkbox", key = "ElecGuitar", default = false, title = "Electric Guitar" },
28                 { type = "checkbox", key = "SoloGuitar", default = false, title = "Guitar Solo" },
29                 { type = "checkbox", key = "AcousticGuitar", default = false, title = "Acoustic Guitar" },
30
31                 { type = "checkbox", key = "basicDrums", default = false, title = "Basic Drum Mics (Kick + Snare)" },
32                 { type = "checkbox", key = "fullDrums", default = false, title = "Full Drum Mics (Kick, Snare, HiHat, 3 Toms)" },
33                 { type = "checkbox", key = "overDrums", default = false, title = "Overkill Drum Mics (Kick (2x), Snare(2x), HiHat, 3 Toms)" },
34
35                 { type = "checkbox", key = "Drum O-Heads (2 mono)", default = false, title = "Drum O-Heads (2 mono)" },
36                 { type = "checkbox", key = "Drum O-Heads (Stereo)", default = false, title = "Drum O-Heads (Stereo)" },
37
38                 { type = "checkbox", key = "Room (Mono)", default = false, title = "Room (Mono)" },
39                 { type = "checkbox", key = "Room (Stereo)", default = false, title = "Room (Stereo)" },
40
41                 { type = "checkbox", key = "BGV", default = false, title = "Background Vocals (3x)" },
42         }
43         local dlg = LuaDialog.Dialog ("Template Setup", dialog_options)
44         local rv = dlg:run()
45         if (not rv) then
46                 return
47         end
48
49         local track_list = {}
50         local channel_count = 0
51
52         function add_track (io, name)
53                 local tl = Session:new_audio_track (io, io, nil, 1, name,  ARDOUR.PresentationInfo.max_order, ARDOUR.TrackMode.Normal)
54                 for track in tl:iter() do
55                         table.insert (track_list, track)
56                         channel_count = channel_count + io
57                 end
58         end
59
60         -- for each selected item, create track(s), add plugins, etc
61         if rv['Bass'] then
62                 add_track (1, "Bass")
63         end
64
65         if rv['Room (Stereo)'] then
66                 add_track (2, "Room (Stereo)")
67         end
68
69         -- TODO add others
70
71
72         -- determine the number of physical inputs
73         local e = Session:engine()
74         -- from the engine's POV readable/capture ports are "outputs"
75         local _, t = e:get_backend_ports ("", ARDOUR.DataType("audio"), ARDOUR.PortFlags.IsOutput | ARDOUR.PortFlags.IsPhysical, C.StringVector())
76         -- table 't' holds argument references. t[4] is the C.StringVector (return value)
77         local num_inputs = t[4]:size()
78
79         if num_inputs < channel_count then
80                 -- warn the user if there are less physical inputs than created tracks
81                 LuaDialog.Message ("Session Creation", "Check your routing :)", LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run ()
82
83         else
84
85                 -- otherwise record arm all created tracks
86                 for _, t in ipairs (track_list) do
87                         t:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
88                 end
89         end
90
91         --fit all tracks on the screen
92         Editor:access_action("Editor","fit_all_tracks")
93
94         Session:save_state("");
95 end end