From: Robin Gareus Date: Thu, 10 Nov 2016 03:54:03 +0000 (+0100) Subject: C++ implementation of fan_out_instrument.lua X-Git-Tag: 5.5~227 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=b116a68a5cea41cc836946bd392197998b93f142;p=ardour.git C++ implementation of fan_out_instrument.lua --- diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index c26b18942a..12a0d837ad 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -1696,6 +1696,11 @@ MixerStrip::build_route_ops_menu () items.push_back (MenuElem (_("Pin Connections..."), sigc::mem_fun (*this, &RouteUI::manage_pins))); } + if (_route->the_instrument () && _route->the_instrument ()->output_streams().n_audio() > 2) { + // TODO ..->n_audio() > 1 && separate_output_groups) hard to check here every time. + items.push_back (MenuElem (_("Fan Out Instrument"), sigc::bind (sigc::mem_fun (*this, &RouteUI::fan_out), false))); + } + items.push_back (SeparatorElem()); items.push_back (MenuElem (_("Adjust Latency..."), sigc::mem_fun (*this, &RouteUI::adjust_latency))); diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 9f204a59fc..ed8873def7 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -17,6 +17,7 @@ */ +#include #include #include @@ -38,11 +39,13 @@ #include "ardour/vca.h" #include "ardour/vca_manager.h" #include "ardour/audio_track.h" +#include "ardour/audio_port.h" #include "ardour/audioengine.h" #include "ardour/filename_extensions.h" #include "ardour/midi_track.h" #include "ardour/monitor_control.h" #include "ardour/internal_send.h" +#include "ardour/panner_shell.h" #include "ardour/profile.h" #include "ardour/phase_control.h" #include "ardour/send.h" @@ -2334,6 +2337,54 @@ RouteUI::manage_pins () } } +void +RouteUI::fan_out (bool to_busses) +{ + boost::shared_ptr pi = boost::dynamic_pointer_cast (_route->the_instrument ()); + assert (pi); + + const uint32_t n_outputs = pi->output_streams ().n_audio (); + if (_route->n_outputs ().n_audio () != n_outputs) { + MessageDialog msg (string_compose ( + _("The Plugin's number of audio outputs ports (%1) does not match the Tracks's number of audio outputs (%2). Cannot fan out."), + n_outputs, _route->n_outputs ().n_audio ())); + msg.run (); + return; + } + boost::shared_ptr plugin = pi->plugin (); + std::map busnames; + for (uint32_t p = 0; p < n_outputs; ++p) { + const Plugin::IOPortDescription& pd (plugin->describe_io_port (DataType::AUDIO, false, p)); + std::string bn = pi->name () + " " + pd.group_name; + busnames[bn]++; + } + + if (busnames.size () < 2) { + MessageDialog msg (_("Instrument has only 1 output bus. Nothing to fan out.")); + msg.run (); + return; + } + + uint32_t outputs = 2; + if (_session->master_out ()) { + outputs = std::max (outputs, _session->master_out ()->n_inputs ().n_audio ()); + } + + _route->output ()->disconnect (this); + _route->panner_shell ()->set_bypassed (true); + + for (uint32_t p = 0; p < n_outputs; ++p) { + const Plugin::IOPortDescription& pd (plugin->describe_io_port (DataType::AUDIO, false, p)); + std::string bn = pi->name () + " " + pd.group_name; + boost::shared_ptr r = _session->route_by_name (bn); + if (!r) { + RouteList rl = _session->new_audio_route (busnames[bn], outputs, NULL, 1, bn, PresentationInfo::AudioBus, PresentationInfo::max_order); + r = rl.front (); + } + _route->output ()->audio (p)->connect (r->input ()->audio (pd.group_channel).get()); + } +} + bool RouteUI::mark_hidden (bool yn) { diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index e05db7f677..41d11fe6c4 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -208,6 +208,7 @@ class RouteUI : public virtual ARDOUR::SessionHandlePtr, public virtual PBD::Sco void manage_pins (); void maybe_add_route_print_mgr (); + void fan_out (bool to_busses = true); virtual void route_property_changed (const PBD::PropertyChange&) = 0; void route_removed ();