summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-11-10 04:54:03 +0100
committerRobin Gareus <robin@gareus.org>2016-11-10 04:54:59 +0100
commitb116a68a5cea41cc836946bd392197998b93f142 (patch)
treecb106737b0c8460366b976321f056c8c08928df9
parentd253d4973916e1a0f26e9b8e3ea80c50fa8c4b8d (diff)
C++ implementation of fan_out_instrument.lua
-rw-r--r--gtk2_ardour/mixer_strip.cc5
-rw-r--r--gtk2_ardour/route_ui.cc51
-rw-r--r--gtk2_ardour/route_ui.h1
3 files changed, 57 insertions, 0 deletions
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 <map>
#include <boost/algorithm/string.hpp>
#include <gtkmm2ext/gtk_ui.h>
@@ -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<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_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> plugin = pi->plugin ();
+ std::map<std::string, uint32_t> 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<Route> 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 ();