diff options
author | Robin Gareus <robin@gareus.org> | 2016-11-10 04:54:42 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-11-10 04:55:03 +0100 |
commit | e34f8dbf1ee7b845bf48a78d6f5148034b455885 (patch) | |
tree | 0f1ce4ca17d4d841c5b6153026aa545dcfc3d011 /scripts/_fan_out_instrument.lua | |
parent | b116a68a5cea41cc836946bd392197998b93f142 (diff) |
don't ship fan-out instrument lua script (but keep it as example)
Diffstat (limited to 'scripts/_fan_out_instrument.lua')
-rw-r--r-- | scripts/_fan_out_instrument.lua | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/scripts/_fan_out_instrument.lua b/scripts/_fan_out_instrument.lua new file mode 100644 index 0000000000..3fdf4ef907 --- /dev/null +++ b/scripts/_fan_out_instrument.lua @@ -0,0 +1,69 @@ +ardour { ["type"] = "EditorAction", name = "Fan Out Instrument", + license = "MIT", + author = "Ardour Team", + description = [[Create Busses for every Instrument Output on selected Tracks]] +} + +function factory () return function () + + local outputs = 2 + local mst = Session:master_out(); + if not mst:isnil() then + outputs = mst:n_inputs():n_audio() + end + mst = nil -- drop reference + + local sel = Editor:get_selection () + for r in sel.tracks:routelist ():iter () do + local proc = r:the_instrument ():to_insert() + if proc:isnil () then + print ("Track", r:name(), "does not have an instrument plugin") + goto next + end + local plugin = proc:plugin(0); + + if (r:n_outputs ():n_audio() ~= proc:output_streams():n_audio()) then + print ("Instrument ", proc:name(), "outputs", proc:output_streams():n_audio(), "do not match track outputs", r:n_outputs ():n_audio()) + goto next + end + + -- collect port-group information, count target bus width + local targets = {} + for i = 1, proc:output_streams():n_audio() do + local pd = plugin:describe_io_port (ARDOUR.DataType("Audio"), false, i - 1) + local nn = proc:name() .. " " .. pd.group_name; -- TODO use track-name prefix? + targets[nn] = targets[nn] or 0 + targets[nn] = targets[nn] + 1 + end + + if #targets < 2 then + print ("Instrument ", proc:name(), "has only 1 output bus. Nothing to fan out.") + goto next + end + + -- create busses ; TODO retain order + for t,c in pairs (targets) do + local rt = Session:route_by_name (t) + if rt:isnil () then + Session:new_audio_route (c, outputs, nil, 1, t, ARDOUR.PresentationInfo.Flag.AudioBus, ARDOUR.PresentationInfo.max_order) + end + end + + r:output():disconnect_all (nil) + r:panner_shell():set_bypassed (true) + + -- connect the busses + for i = 1, proc:output_streams():n_audio() do + local pd = plugin:describe_io_port (ARDOUR.DataType("Audio"), false, i - 1) + local nn = proc:name() .. " " .. pd.group_name; + local rt = Session:route_by_name (nn) + assert (rt) + + local op = r:output():audio (i - 1) + local ip = rt:input():audio (pd.group_channel) + op:connect (ip:name()) + end + + ::next:: + end +end end |