1 ardour { ["type"] = "EditorAction", name = "Send Tracks to Bus",
3 author = "Ardour Team",
4 description = [[Create a Bus and add aux-sends from all selected tracks]]
7 function factory () return function ()
8 -- find number of channels to use for the new bus, follow master-bus' inputs
10 local mst = Session:master_out();
11 if not mst:isnil() then
12 chn = mst:n_inputs():n_audio()
14 mst = nil -- explicitly drop reference
16 local sel = Editor:get_selection () -- get selection
17 local tracks = ARDOUR.RouteListPtr() -- create a new list
19 -- find selected *tracks*, add to tracks list
20 for r in sel.tracks:routelist ():iter () do
21 if r:to_track():isnil() then
28 if tracks:size() > 0 then
29 local bus = Session:new_audio_route (chn, chn, nil, 1, "", ARDOUR.PresentationInfo.Flag.AudioBus, ARDOUR.PresentationInfo.max_order)
30 if bus:size () > 0 then
31 Session:add_internal_sends (bus:front(), ARDOUR.Placement.PostFader, tracks);
36 function icon (params) return function (ctx, width, height, fg)
37 local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil(math.min (width, height) * .5) .. "px")
38 txt:set_text ("\u{2192}B") -- "->B"
39 local tw, th = txt:get_pixel_size ()
40 ctx:move_to (.5 * (width - tw), .5 * (height - th))
41 ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg))
42 txt:show_in_cairo_context (ctx)