summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-02-20 00:29:39 +0100
committerRobin Gareus <robin@gareus.org>2017-02-20 00:30:15 +0100
commit44852aa529d5a06ecfe6eaff151bc1f2c503752f (patch)
tree6a716c95e072406fc54fb2293f34f15fac68d817 /scripts
parentda8f49829f629eadebe6dbfe72a1bdc3b84c1ae9 (diff)
Add a Lua script to send multiple tracks to an aux-bus.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/send_to_bus.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/send_to_bus.lua b/scripts/send_to_bus.lua
new file mode 100644
index 0000000000..a391b13108
--- /dev/null
+++ b/scripts/send_to_bus.lua
@@ -0,0 +1,43 @@
+ardour { ["type"] = "EditorAction", name = "Send Tracks to Bus",
+ license = "MIT",
+ author = "Ardour Team",
+ description = [[Create a Bus and add aux-sends from all selected tracks]]
+}
+
+function factory () return function ()
+ -- find number of channels to use for the new bus, follow master-bus' inputs
+ local chn = 2
+ local mst = Session:master_out();
+ if not mst:isnil() then
+ chn = mst:n_inputs():n_audio()
+ end
+ mst = nil -- explicitly drop reference
+
+ local sel = Editor:get_selection () -- get selection
+ local tracks = ARDOUR.RouteListPtr() -- create a new list
+
+ -- find selected *tracks*, add to tracks list
+ for r in sel.tracks:routelist ():iter () do
+ if r:to_track():isnil() then
+ goto next
+ end
+ tracks:push_back (r)
+ ::next::
+ end
+
+ if tracks:size() > 0 then
+ local bus = Session:new_audio_route (chn, chn, nil, 1, "", ARDOUR.PresentationInfo.Flag.AudioBus, ARDOUR.PresentationInfo.max_order)
+ if bus:size () > 0 then
+ Session:add_internal_sends (bus:front(), ARDOUR.Placement.PostFader, tracks);
+ end
+ end
+end end
+
+function icon (params) return function (ctx, width, height, fg)
+ local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil(math.min (width, height) * .5) .. "px")
+ txt:set_text ("\u{2192}B") -- "->B"
+ local tw, th = txt:get_pixel_size ()
+ ctx:move_to (.5 * (width - tw), .5 * (height - th))
+ ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg))
+ txt:show_in_cairo_context (ctx)
+end end