2 ["type"] = "EditorAction",
5 This template helps create the tracks for a typical pop/rock band.
7 You will be prompted to assemble your session from a list of suggested tracks.
9 You may rename each track, and you may choose whether it is mono (default) or stereo.
11 Optionally, tracks may be assigned to sensible Groups ( vocals, guitars, drums )
13 Each track will be pre-assigned a color corresponding to its group.
15 Optionally, tracks may be assigned Gates and other plugins.
17 This script is developed in Lua, and can be duplicated and/or modified to meet your needs.
21 function session_setup ()
25 function route_setup ()
28 ['Insert_at'] = ARDOUR.PresentationInfo.max_order
32 function factory (params) return function ()
34 --at session load, params will be empty. in this case we can do things that we -only- want to do if this is a new session
36 Editor:set_toggleaction ("Rulers", "toggle-tempo-ruler", 1)
37 Editor:set_toggleaction ("Rulers", "toggle-meter-ruler", 1)
39 Editor:set_toggleaction ("Transport", "primary-clock-bbt", 1)
40 Editor:set_toggleaction ("Transport", "secondary-clock-off", 1)
42 Editor:set_toggleaction ("Rulers", "toggle-minsec-ruler", 0)
43 Editor:set_toggleaction ("Rulers", "toggle-samples-ruler", 0)
44 Editor:set_toggleaction ("Rulers", "toggle-bbt-ruler", 1)
48 local p = params or route_setup ()
49 local insert_at = p["insert_at"] or ARDOUR.PresentationInfo.max_order
51 --prompt the user for the tracks they'd like to instantiate
52 local dialog_options = {
53 { type = "heading", title = "Track Type: ", col=0, align = "left", colspan = 1},
54 { type = "heading", title = "Track Name:", align = "left", col=1, colspan = 1 },
55 { type = "heading", title = "Stereo?", align = "left", col=2, colspan = 1 },
57 { type = "checkbox", key = "check-ldvox", default = false, title = "Lead Vocal", col=0 },
58 { type = "entry", key = "name-ldvox", default = "Ld Vox", title = "", col=1 },
59 { type = "checkbox", key = "stereo-ldvox", default = false, title = "", col=2 },
61 { type = "checkbox", key = "check-bass", default = false, title = "Bass", col=0 },
62 { type = "entry", key = "name-bass", default = "Bass", title = "", col=1 },
63 { type = "checkbox", key = "stereo-bass", default = false, title = "", col=2 },
65 { type = "checkbox", key = "check-piano", default = false, title = "Piano", col=0 },
66 { type = "entry", key = "name-piano", default = "Piano", title = "", col=1 },
67 { type = "checkbox", key = "stereo-piano", default = false, title = "", col=2 },
69 { type = "checkbox", key = "check-electric-piano", default = false, title = "Electric Piano", col=0 },
70 { type = "entry", key = "name-electric-piano", default = "E Piano", title = "", col=1 },
71 { type = "checkbox", key = "stereo-electric-piano", default = false, title = "", col=2 },
73 { type = "checkbox", key = "check-organ", default = false, title = "Organ", col=0 },
74 { type = "entry", key = "name-organ", default = "Organ", title = "", col=1 },
75 { type = "checkbox", key = "stereo-organ", default = false, title = "", col=2 },
77 { type = "checkbox", key = "check-electric-guitar", default = false, title = "Electric Guitar", col=0 },
78 { type = "entry", key = "name-electric-guitar", default = "E Gtr", title = "", col=1 },
79 { type = "checkbox", key = "stereo-electric-guitar", default = false, title = "", col=2 },
81 { type = "checkbox", key = "check-solo-guitar", default = false, title = "Lead Guitar", col=0 },
82 { type = "entry", key = "name-solo-guitar", default = "Ld Gtr", title = "", col=1 },
83 { type = "checkbox", key = "stereo-solo-guitar", default = false, title = "", col=2 },
85 { type = "checkbox", key = "check-accoustic-guitar", default = false, title = "Acoustic Guitar", col=0 },
86 { type = "entry", key = "name-accoustic-guitar", default = "Ac Gtr", title = "", col=1 },
87 { type = "checkbox", key = "stereo-accoustic-guitar", default = false, title = "", col=2 },
89 { type = "checkbox", key = "check-bgvox", default = false, title = "Background Vocals", col=0 },
90 { type = "label", title = "BGV1, BGV2, BGV3", col=1, colspan = 1, align = "left"},
91 { type = "checkbox", key = "stereo-bgvox", default = false, title = "", col=2 },
93 { type = "checkbox", key = "check-overhead", default = false, title = "Drum Overheads", col=0 },
94 { type = "label", title = "OH {OH L, OH R}", col=1, colspan = 1, align = "left"},
95 { type = "checkbox", key = "stereo-overhead", default = false, title = "", col=2 },
97 { type = "checkbox", key = "check-room", default = false, title = "Drum Room", col=0 },
98 { type = "label", title = "Room {Rm L, Rm R}", col=1, colspan = 1, align = "left"},
99 { type = "checkbox", key = "stereo-room", default = false, title = "", col=2 },
101 { type = "checkbox", key = "check-basic-kit", default = false, title = "Basic Drum Mics", col=0 },
102 { type = "label", title = "Kick, Snare", col=1, colspan = 1, align = "left"},
104 { type = "checkbox", key = "check-full-kit", default = false, title = "Full Drum Mics", col=0 },
105 { type = "label", title = "Hi-Hat, Hi-tom, Mid-Tom, Fl-Tom", col=1, colspan = 1, align = "left"},
107 { type = "checkbox", key = "check-overkill-kit", default = false, title = "Overkill Drum Mics", col=0 },
108 { type = "label", title = "Kick Beater, Snare Btm", col=1, colspan = 1, align = "left"},
110 { type = "hseparator", title="", col=0, colspan = 3},
112 { type = "checkbox", key = "group", default = false, title = "Group Track(s)?", col=0 },
115 --- check for available plugins
117 local xt_eg = not ARDOUR.LuaAPI.new_plugin_info ("XT-EG Expander Gate (Mono)", ARDOUR.PluginType.LV2):isnil ()
118 local xt_tg = not ARDOUR.LuaAPI.new_plugin_info ("XT-TG Tom Gate (Mono", ARDOUR.PluginType.LV2):isnil ()
120 local xt_tg = not ARDOUR.LuaAPI.new_plugin_info ("XT-BC Bass Character (Mono)", ARDOUR.PluginType.LV2):isnil ()
121 local xt_vc = not ARDOUR.LuaAPI.new_plugin_info ("XT-VC Vocal Character (Mono)", ARDOUR.PluginType.LV2):isnil ()
123 if (xt_eg and xt_tg) then
124 table.insert (dialog_options,
125 { type = "checkbox", key = "gates", default = false, title = "Add Gate(s)?", col=0 }
128 if (xt_tg and xt_vc) then
129 table.insert (dialog_options,
130 { type = "checkbox", key = "char", default = false, title = "Add Character Plugin(s)?", col=0 }
136 local dlg = LuaDialog.Dialog ("Template Setup", dialog_options)
142 -- helper function to reference processors
143 function processor(t, s) --takes a track (t) and a string (s) as arguments
145 local proc = t:nth_processor(i)
147 if ( proc:display_name() == s ) then
152 proc = t:nth_processor(i)
156 --INSTANTIATING MIDI TRACKS IS TOO DAMN HARD
157 function create_midi_track(name, chan_count) -- call this function with a name argument and output channel count
158 Session:new_midi_track(ARDOUR.ChanCount(ARDOUR.DataType ("midi"), 1), ARDOUR.ChanCount(ARDOUR.DataType ("audio"), chan_count), true, ARDOUR.PluginInfo(), nil, nil, 1, name, 1, ARDOUR.TrackMode.Normal)
162 function add_lv2_plugin (track, pluginname, position)
163 local p = ARDOUR.LuaAPI.new_plugin(Session, pluginname, ARDOUR.PluginType.LV2, "")
164 if not p:isnil () then
165 track:add_processor_by_index(p, position, nil, true)
170 local drum_group, bass_group, guitar_group, key_group, vox_group
173 drum_group = Session:new_route_group("Drums")
174 drum_group:set_rgba(0x425CADff)
175 bass_group = Session:new_route_group("Bass")
176 bass_group:set_rgba(0x1AE54Eff)
177 guitar_group = Session:new_route_group("Guitars")
178 guitar_group:set_rgba(0xB475CBff)
179 key_group = Session:new_route_group("Keys")
180 key_group:set_rgba(0xDA8032ff)
181 vox_group = Session:new_route_group("Vox")
182 vox_group:set_rgba(0xC54249ff)
185 local channel_count = 0
187 if rv['check-basic-kit'] then
188 local names = {"Kick", "Snare"}
190 local tl = Session:new_audio_track (1, 1, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
191 for track in tl:iter() do
192 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
193 if rv['group'] then drum_group:add(track) end
195 add_lv2_plugin (track, "XT-EG Expander Gate (Mono)", 0)
199 channel_count = channel_count + #names
202 if rv['check-full-kit'] then
203 local names = {"Hi-Hat", "Hi-tom", "Mid-tom", "Fl-tom"}
205 local tl = Session:new_audio_track (1, 1, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
206 for track in tl:iter() do
207 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
208 if rv['group'] then drum_group:add(track) end
210 if string.find(track:name(), '-tom') then
211 add_lv2_plugin (track, "XT-TG Tom Gate (Mono)", 0)
213 add_lv2_plugin (track, "XT-EG Expander Gate (Mono)", 0)
218 channel_count = channel_count + #names
221 if rv['check-overkill-kit'] then
222 local names = {"Kick Beater", "Snare Btm"}
224 local tl = Session:new_audio_track (1, 1, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
225 for track in tl:iter() do
226 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
227 if rv['group'] then drum_group:add(track) end
229 if string.find(track:name(), '-tom') then
230 add_lv2_plugin (track, "XT-TG Tom Gate (Mono)", 0)
232 add_lv2_plugin (track, "XT-EG Expander Gate (Mono)", 0)
237 channel_count = channel_count + #names
240 if rv['check-overhead'] then
241 local names = { "OH" }
243 if rv["stereo-overhead"] then ch = 2 end --stereo
245 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
246 for track in tl:iter() do
247 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
248 if rv['group'] then drum_group:add(track) end
251 channel_count = channel_count + ch
255 if rv['check-room'] then
256 local names = { "Drum Room" }
258 if rv["stereo-room"] then ch = 2 end --stereo
260 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
261 for track in tl:iter() do
262 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
263 if rv['group'] then drum_group:add(track) end
266 channel_count = channel_count + ch
269 if rv['check-bass'] then
270 local names = { rv["name-bass"] }
272 if rv["stereo-bass"] then ch = 2 end --stereo
274 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
275 for track in tl:iter() do
276 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
277 if rv['group'] then bass_group:add(track) end
279 add_lv2_plugin (track, "XT-BC Bass Character (Mono)", 0)
283 channel_count = channel_count + ch
286 if rv['check-electric-guitar'] then
287 local names = { rv["name-electric-guitar"] }
289 if rv["stereo-electric-guitar"] then ch = 2 end --stereo
291 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
292 for track in tl:iter() do
293 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
294 if rv['group'] then guitar_group:add(track) end
297 channel_count = channel_count + ch
300 if rv['check-solo-guitar'] then
301 local names = { rv["name-solo-guitar"] }
303 if rv["stereo-solo-guitar"] then ch = 2 end --stereo
305 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
306 for track in tl:iter() do
307 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
308 if rv['group'] then guitar_group:add(track) end
312 channel_count = channel_count + ch
315 if rv['check-acoustic-guitar'] then
316 local names = { rv["name-acoustic-guitar"] }
318 if rv["stereo-acoustic-guitar"] then ch = 2 end --stereo
320 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
321 for track in tl:iter() do
322 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
323 if rv['group'] then guitar_group:add(track) end
327 channel_count = channel_count + ch
330 if rv['check-piano'] then
331 local names = { rv["name-piano"] }
333 if rv["stereo-piano"] then ch = 2 end --stereo
335 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
336 for track in tl:iter() do
337 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
338 if rv['group'] then key_group:add(track) end
342 channel_count = channel_count + ch
345 if rv['check-electric-piano'] then
346 local names = { rv["name-electric-piano"] }
348 if rv["stereo-electric-piano"] then ch = 2 end --stereo
350 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
351 for track in tl:iter() do
352 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
353 if rv['group'] then key_group:add(track) end
356 channel_count = channel_count + ch
359 if rv['check-organ'] then
360 local names = { rv["name-organ"] }
362 if rv["stereo-organ"] then ch = 2 end --stereo
364 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
365 for track in tl:iter() do
366 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
367 if rv['group'] then key_group:add(track) end
370 channel_count = channel_count + ch
373 if rv['check-ldvox'] then
374 local names = { rv["name-ldvox"] }
376 if rv["stereo-ldvox"] then ch = 2 end --stereo
378 local tl = Session:new_audio_track ( ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
379 for track in tl:iter() do
380 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
381 if rv['group'] then vox_group:add(track) end
383 add_lv2_plugin (track, "XT-VC Vocal Character (Mono)", 0)
387 channel_count = channel_count + ch
390 if rv['check-bgvox'] then
391 local names = { rv["name-bgvox"] }
393 if rv["stereo-bgvox"] then ch = 2 end --stereo
395 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
396 for track in tl:iter() do
397 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
398 if rv['group'] then vox_group:add(track) end
401 channel_count = channel_count + ch
404 --fit all tracks on the screen
405 Editor:access_action("Editor","fit_all_tracks")
407 Session:save_state("")
409 -- determine the number of channels we can record
410 local e = Session:engine()
411 local _, t = e:get_backend_ports ("", ARDOUR.DataType("audio"), ARDOUR.PortFlags.IsOutput | ARDOUR.PortFlags.IsPhysical, C.StringVector()) -- from the engine's POV readable/capture ports are "outputs"
412 local num_inputs = t[4]:size() -- table 't' holds argument references. t[4] is the C.StringVector (return value)
414 if num_inputs < channel_count then
415 -- warn the user if there are less physical inputs than created tracks
416 LuaDialog.Message ("Session Creation",
417 "Created more tracks than there are physical inputs on the soundcard",
418 LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run ()