The following Lua script lets Ardour 9.0 and 9.2 crash but works on 8.12.
Yes the script is rough and even has some “IDK why” comments but as stated it did what i needed in 8.12. Do i have to adjust something for 9 or is this a bug in Ardour?
ardour { ["type"] = "EditorAction",
name = "Add Tracks To Selected Buses",
license = "MIT",
author = "d-night-audio",
description = [[Adds a Track for every selected Bus and routes the output of that Bus to the Track input]]
}
function factory () return function ()
-- prepare undo operation
Session:begin_reversible_command ("Add Tracks To Selected Buses")
local add_undo = false -- keep track if something has changed
local rlp = ARDOUR.RouteListPtr ()
local selbus = Editor:get_selection ()
local a = Session:engine()
-- loop over all tracks in the session
for selectedBusses in selbus.tracks:routelist ():iter() do
-- get track name and add "sw_"
get_name = selectedBusses:name ()
get_name = "sw_" .. get_name
-- add tracks
--local sel = Editor:get_selection ()
local ctrls = ARDOUR.ControlListPtr () -- create a list of controls to change
if not Editor:get_selection ():empty () and not Editor:get_selection ().tracks:routelist ():empty () then
tr = Session:new_audio_track (1, 2, nil, 1, get_name, Editor:get_selection ().tracks:routelist ():front():presentation_info_ptr ():order () + 1, ARDOUR.TrackMode.Normal, true)
else
tr = Session:new_audio_track (1, 2, nil, 1, get_name, -1, ARDOUR.TrackMode.Normal, true)
end
-- mute and rec enable the tracks
for track in tr:iter() do
track:mute_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
-- reroute
_, t = a:get_ports (ARDOUR.DataType("audio"), ARDOUR.PortList())
for p in t[2]:iter() do
if (p:name ():find (track:name ())) then
print (p:name())
-- real rerouting starts here
a:disconnect_port(p)
busport = selectedBusses:name() .. "/audio_out 1"
p:connect(busport)
end
end
end
--don't know why this is necessery
rlp:push_back (selectedBusses)
end
-- all done. now commit the combined undo operation
if add_undo then
-- the 'nil' command here means to use all collected diffs
Session:commit_reversible_command (nil)
else
Session:abort_reversible_command ()
end
end end