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", true)
37 Editor:set_toggleaction ("Rulers", "toggle-meter-ruler", true)
39 Editor:access_action ("Transport", "primary-clock-bbt")
40 Editor:access_action ("Transport", "secondary-clock-minsec")
42 Editor:set_toggleaction ("Rulers", "toggle-minsec-ruler", false)
43 Editor:set_toggleaction ("Rulers", "toggle-timecode-ruler", false)
44 Editor:set_toggleaction ("Rulers", "toggle-samples-ruler", false)
46 Editor:set_toggleaction ("Rulers", "toggle-bbt-ruler", true)
50 local p = params or route_setup ()
51 local insert_at = p["insert_at"] or ARDOUR.PresentationInfo.max_order
53 --prompt the user for the tracks they'd like to instantiate
54 local dialog_options = {
55 { type = "heading", title = "Track Type: ", col=0, align = "left", colspan = 1},
56 { type = "heading", title = "Track Name:", align = "left", col=1, colspan = 1 },
57 { type = "heading", title = "Stereo?", align = "left", col=2, colspan = 1 },
59 { type = "checkbox", key = "check-ldvox", default = false, title = "Lead Vocal", col=0 },
60 { type = "entry", key = "name-ldvox", default = "Ld Vox", title = "", col=1 },
61 { type = "checkbox", key = "stereo-ldvox", default = false, title = "", col=2 },
63 { type = "checkbox", key = "check-bass", default = false, title = "Bass", col=0 },
64 { type = "entry", key = "name-bass", default = "Bass", title = "", col=1 },
65 { type = "checkbox", key = "stereo-bass", default = false, title = "", col=2 },
67 { type = "checkbox", key = "check-piano", default = false, title = "Piano", col=0 },
68 { type = "entry", key = "name-piano", default = "Piano", title = "", col=1 },
69 { type = "checkbox", key = "stereo-piano", default = false, title = "", col=2 },
71 { type = "checkbox", key = "check-electric-piano", default = false, title = "Electric Piano", col=0 },
72 { type = "entry", key = "name-electric-piano", default = "E Piano", title = "", col=1 },
73 { type = "checkbox", key = "stereo-electric-piano", default = false, title = "", col=2 },
75 { type = "checkbox", key = "check-organ", default = false, title = "Organ", col=0 },
76 { type = "entry", key = "name-organ", default = "Organ", title = "", col=1 },
77 { type = "checkbox", key = "stereo-organ", default = false, title = "", col=2 },
79 { type = "checkbox", key = "check-electric-guitar", default = false, title = "Electric Guitar", col=0 },
80 { type = "entry", key = "name-electric-guitar", default = "E Gtr", title = "", col=1 },
81 { type = "checkbox", key = "stereo-electric-guitar", default = false, title = "", col=2 },
83 { type = "checkbox", key = "check-solo-guitar", default = false, title = "Lead Guitar", col=0 },
84 { type = "entry", key = "name-solo-guitar", default = "Ld Gtr", title = "", col=1 },
85 { type = "checkbox", key = "stereo-solo-guitar", default = false, title = "", col=2 },
87 { type = "checkbox", key = "check-accoustic-guitar", default = false, title = "Acoustic Guitar", col=0 },
88 { type = "entry", key = "name-accoustic-guitar", default = "Ac Gtr", title = "", col=1 },
89 { type = "checkbox", key = "stereo-accoustic-guitar", default = false, title = "", col=2 },
91 { type = "checkbox", key = "check-bgvox", default = false, title = "Background Vocals", col=0 },
92 { type = "label", title = "BGV1, BGV2, BGV3", col=1, colspan = 1, align = "left"},
93 { type = "checkbox", key = "stereo-bgvox", default = false, title = "", col=2 },
95 { type = "checkbox", key = "check-overhead", default = false, title = "Drum Overheads", col=0 },
96 { type = "label", title = "OH {OH L, OH R}", col=1, colspan = 1, align = "left"},
97 { type = "checkbox", key = "stereo-overhead", default = false, title = "", col=2 },
99 { type = "checkbox", key = "check-room", default = false, title = "Drum Room", col=0 },
100 { type = "label", title = "Room {Rm L, Rm R}", col=1, colspan = 1, align = "left"},
101 { type = "checkbox", key = "stereo-room", default = false, title = "", col=2 },
103 { type = "checkbox", key = "check-basic-kit", default = false, title = "Basic Drum Mics", col=0 },
104 { type = "label", title = "Kick, Snare", col=1, colspan = 1, align = "left"},
106 { type = "checkbox", key = "check-full-kit", default = false, title = "Full Drum Mics", col=0 },
107 { type = "label", title = "Hi-Hat, Hi-tom, Mid-Tom, Fl-Tom", col=1, colspan = 1, align = "left"},
109 { type = "checkbox", key = "check-overkill-kit", default = false, title = "Overkill Drum Mics", col=0 },
110 { type = "label", title = "Kick Beater, Snare Btm", col=1, colspan = 1, align = "left"},
112 { type = "hseparator", title="", col=0, colspan = 3},
114 { type = "checkbox", key = "group", default = false, title = "Group Track(s)?", col=0 },
117 --- check for available plugins
119 local xt_eg = not ARDOUR.LuaAPI.new_plugin_info ("XT-EG Expander Gate (Mono)", ARDOUR.PluginType.LV2):isnil ()
120 local xt_tg = not ARDOUR.LuaAPI.new_plugin_info ("XT-TG Tom Gate (Mono", ARDOUR.PluginType.LV2):isnil ()
122 local xt_tg = not ARDOUR.LuaAPI.new_plugin_info ("XT-BC Bass Character (Mono)", ARDOUR.PluginType.LV2):isnil ()
123 local xt_vc = not ARDOUR.LuaAPI.new_plugin_info ("XT-VC Vocal Character (Mono)", ARDOUR.PluginType.LV2):isnil ()
125 if (xt_eg and xt_tg) then
126 table.insert (dialog_options,
127 { type = "checkbox", key = "gates", default = false, title = "Add Gate(s)?", col=0 }
130 if (xt_tg and xt_vc) then
131 table.insert (dialog_options,
132 { type = "checkbox", key = "char", default = false, title = "Add Character Plugin(s)?", col=0 }
138 local dlg = LuaDialog.Dialog ("Template Setup", dialog_options)
144 -- helper function to reference processors
145 function processor(t, s) --takes a track (t) and a string (s) as arguments
147 local proc = t:nth_processor(i)
149 if ( proc:display_name() == s ) then
154 proc = t:nth_processor(i)
158 --INSTANTIATING MIDI TRACKS IS TOO DAMN HARD
159 function create_midi_track(name, chan_count) -- call this function with a name argument and output channel count
160 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)
164 function add_lv2_plugin (track, pluginname, position)
165 local p = ARDOUR.LuaAPI.new_plugin(Session, pluginname, ARDOUR.PluginType.LV2, "")
166 if not p:isnil () then
167 track:add_processor_by_index(p, position, nil, true)
172 local drum_group, bass_group, guitar_group, key_group, vox_group
175 drum_group = Session:new_route_group("Drums")
176 drum_group:set_rgba(0x425CADff)
177 bass_group = Session:new_route_group("Bass")
178 bass_group:set_rgba(0x1AE54Eff)
179 guitar_group = Session:new_route_group("Guitars")
180 guitar_group:set_rgba(0xB475CBff)
181 key_group = Session:new_route_group("Keys")
182 key_group:set_rgba(0xDA8032ff)
183 vox_group = Session:new_route_group("Vox")
184 vox_group:set_rgba(0xC54249ff)
187 local channel_count = 0
189 if rv['check-basic-kit'] then
190 local names = {"Kick", "Snare"}
192 local tl = Session:new_audio_track (1, 1, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
193 for track in tl:iter() do
194 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
195 if rv['group'] then drum_group:add(track) end
197 add_lv2_plugin (track, "XT-EG Expander Gate (Mono)", 0)
201 channel_count = channel_count + #names
204 if rv['check-full-kit'] then
205 local names = {"Hi-Hat", "Hi-tom", "Mid-tom", "Fl-tom"}
207 local tl = Session:new_audio_track (1, 1, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
208 for track in tl:iter() do
209 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
210 if rv['group'] then drum_group:add(track) end
212 if string.find(track:name(), '-tom') then
213 add_lv2_plugin (track, "XT-TG Tom Gate (Mono)", 0)
215 add_lv2_plugin (track, "XT-EG Expander Gate (Mono)", 0)
220 channel_count = channel_count + #names
223 if rv['check-overkill-kit'] then
224 local names = {"Kick Beater", "Snare Btm"}
226 local tl = Session:new_audio_track (1, 1, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
227 for track in tl:iter() do
228 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
229 if rv['group'] then drum_group:add(track) end
231 if string.find(track:name(), '-tom') then
232 add_lv2_plugin (track, "XT-TG Tom Gate (Mono)", 0)
234 add_lv2_plugin (track, "XT-EG Expander Gate (Mono)", 0)
239 channel_count = channel_count + #names
242 if rv['check-overhead'] then
243 local names = { "OH" }
245 if rv["stereo-overhead"] then ch = 2 end --stereo
247 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
248 for track in tl:iter() do
249 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
250 if rv['group'] then drum_group:add(track) end
253 channel_count = channel_count + ch
257 if rv['check-room'] then
258 local names = { "Drum Room" }
260 if rv["stereo-room"] then ch = 2 end --stereo
262 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
263 for track in tl:iter() do
264 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
265 if rv['group'] then drum_group:add(track) end
268 channel_count = channel_count + ch
271 if rv['check-bass'] then
272 local names = { rv["name-bass"] }
274 if rv["stereo-bass"] then ch = 2 end --stereo
276 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
277 for track in tl:iter() do
278 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
279 if rv['group'] then bass_group:add(track) end
281 add_lv2_plugin (track, "XT-BC Bass Character (Mono)", 0)
285 channel_count = channel_count + ch
288 if rv['check-electric-guitar'] then
289 local names = { rv["name-electric-guitar"] }
291 if rv["stereo-electric-guitar"] then ch = 2 end --stereo
293 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
294 for track in tl:iter() do
295 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
296 if rv['group'] then guitar_group:add(track) end
299 channel_count = channel_count + ch
302 if rv['check-solo-guitar'] then
303 local names = { rv["name-solo-guitar"] }
305 if rv["stereo-solo-guitar"] then ch = 2 end --stereo
307 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
308 for track in tl:iter() do
309 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
310 if rv['group'] then guitar_group:add(track) end
314 channel_count = channel_count + ch
317 if rv['check-acoustic-guitar'] then
318 local names = { rv["name-acoustic-guitar"] }
320 if rv["stereo-acoustic-guitar"] then ch = 2 end --stereo
322 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
323 for track in tl:iter() do
324 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
325 if rv['group'] then guitar_group:add(track) end
329 channel_count = channel_count + ch
332 if rv['check-piano'] then
333 local names = { rv["name-piano"] }
335 if rv["stereo-piano"] then ch = 2 end --stereo
337 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
338 for track in tl:iter() do
339 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
340 if rv['group'] then key_group:add(track) end
344 channel_count = channel_count + ch
347 if rv['check-electric-piano'] then
348 local names = { rv["name-electric-piano"] }
350 if rv["stereo-electric-piano"] then ch = 2 end --stereo
352 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
353 for track in tl:iter() do
354 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
355 if rv['group'] then key_group:add(track) end
358 channel_count = channel_count + ch
361 if rv['check-organ'] then
362 local names = { rv["name-organ"] }
364 if rv["stereo-organ"] then ch = 2 end --stereo
366 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
367 for track in tl:iter() do
368 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
369 if rv['group'] then key_group:add(track) end
372 channel_count = channel_count + ch
375 if rv['check-ldvox'] then
376 local names = { rv["name-ldvox"] }
378 if rv["stereo-ldvox"] then ch = 2 end --stereo
380 local tl = Session:new_audio_track ( ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
381 for track in tl:iter() do
382 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
383 if rv['group'] then vox_group:add(track) end
385 add_lv2_plugin (track, "XT-VC Vocal Character (Mono)", 0)
389 channel_count = channel_count + ch
392 if rv['check-bgvox'] then
393 local names = { rv["name-bgvox"] }
395 if rv["stereo-bgvox"] then ch = 2 end --stereo
397 local tl = Session:new_audio_track (ch, ch, nil, 1, names[i], insert_at, ARDOUR.TrackMode.Normal)
398 for track in tl:iter() do
399 --track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
400 if rv['group'] then vox_group:add(track) end
403 channel_count = channel_count + ch
406 --fit all tracks on the screen
407 Editor:access_action("Editor","fit_all_tracks")
409 Session:save_state("")
411 -- determine the number of channels we can record
412 local e = Session:engine()
413 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"
414 local num_inputs = t[4]:size() -- table 't' holds argument references. t[4] is the C.StringVector (return value)
416 if num_inputs < channel_count then
417 -- warn the user if there are less physical inputs than created tracks
418 LuaDialog.Message ("Session Creation",
419 "Created more tracks than there are physical inputs on the soundcard",
420 LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run ()