From a68ddd39be1a09447c42bdcdb0812807d5d16ee7 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 1 Jul 2021 20:15:04 +0200 Subject: [PATCH] Auto-connect newly added plugin output pins --- gtk2_ardour/plugin_pin_dialog.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gtk2_ardour/plugin_pin_dialog.cc b/gtk2_ardour/plugin_pin_dialog.cc index 35e5b8e6eb..1db51ecba3 100644 --- a/gtk2_ardour/plugin_pin_dialog.cc +++ b/gtk2_ardour/plugin_pin_dialog.cc @@ -1636,9 +1636,22 @@ PluginPinWidget::add_remove_port_clicked (bool add, ARDOUR::DataType dt) ChanCount out = _out; ChanCount sinks = _sinks; assert (add || out.get (dt) > 0); + uint32_t n_before = std::min (out.get (dt), _sources.get (dt) * _n_plugins); out.set (dt, out.get (dt) + (add ? 1 : -1)); if (!_route ()->customize_plugin_insert (_pi, _n_plugins, out, sinks)) { error_message_dialog (_("Failed to alter plugin output configuration.")); + } else if (add && dt == DataType::AUDIO) { + ChanCount ins, outs, src; + _pi->configured_io (ins, outs); + src = _pi->natural_output_streams (); + for (uint32_t i = n_before; i < outs.get (dt); ++i) { + uint32_t pc = i / src.get (dt); + uint32_t pn = i % src.get (dt); + assert (pc <= _n_plugins); + ChanMapping map (_pi->output_map (pc)); + map.set (dt, pn, pn); + _pi->set_output_map (pc, map); + } } }