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 not r:to_track ():isnil () then
26 if tracks:size () > 0 then
27 local bus = Session:new_audio_route (chn, chn, nil, 1, "", ARDOUR.PresentationInfo.Flag.AudioBus, ARDOUR.PresentationInfo.max_order)
28 if bus:size () > 0 then
29 Session:add_internal_sends (bus:front (), ARDOUR.Placement.PostFader, tracks);
34 function icon (params) return function (ctx, width, height, fg)
35 local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil (math.min (width, height) * .5) .. "px")
36 txt:set_text ("\u{2192}B") -- "->B"
37 local tw, th = txt:get_pixel_size ()
38 ctx:move_to (.5 * (width - tw), .5 * (height - th))
39 ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg))
40 txt:show_in_cairo_context (ctx)