diff options
author | Robin Gareus <robin@gareus.org> | 2016-11-10 01:30:11 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-11-10 01:32:08 +0100 |
commit | ce77df24cad242e7a8f4bc4f05ab552f629956c7 (patch) | |
tree | b86b9c9694b1960ee07a129f7ed46d580c017278 /scripts | |
parent | da937cf1a404f81dee09322c3d9fe8d68d4749e0 (diff) |
prototype script to fan out instrument outputs to busses
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/fan_out_instrument.lua | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/fan_out_instrument.lua b/scripts/fan_out_instrument.lua new file mode 100644 index 0000000000..a2561cb428 --- /dev/null +++ b/scripts/fan_out_instrument.lua @@ -0,0 +1,62 @@ +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 instrumenr plugin") + goto next + end + local plugin = proc:plugin(0); + + if (r:n_outputs ():n_audio() ~= proc:output_streams():n_audio()) then + print ("Instrument 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 + + -- create busses + 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) + + 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) + + local op = r:output():audio (i - 1) + local ip = rt:input():audio (pd.group_channel) + op:connect (ip:name()) + end + + ::next:: + end +end end |