From 2644aaddb19eda57551129c4e6ca6ca02fdb066a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 1 Jan 2014 15:34:06 +0100 Subject: [PATCH] visualize port connections in mixer/processor when in < out --- gtk2_ardour/processor_box.cc | 74 +++++++++++++++++++++--------- gtk2_ardour/processor_box.h | 11 +++-- libs/ardour/ardour/plugin_insert.h | 3 +- libs/ardour/plugin_insert.cc | 11 +++-- 4 files changed, 70 insertions(+), 29 deletions(-) diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 011d2226f4..08079f4f91 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -602,7 +602,7 @@ PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost:: : ProcessorEntry (b, p, w) , _plugin_insert (p) { - p->SplittingChanged.connect ( + p->PluginIoReConfigure.connect ( _splitting_connection, invalidator (*this), boost::bind (&PluginInsertProcessorEntry::plugin_insert_splitting_changed, this), gui_context() ); @@ -617,9 +617,17 @@ PluginInsertProcessorEntry::PluginInsertProcessorEntry (ProcessorBox* b, boost:: void PluginInsertProcessorEntry::plugin_insert_splitting_changed () { - if (_plugin_insert->splitting ()) { - _splitting_icon.set_branches(_plugin_insert->output_streams().n_audio()); + _splitting_icon.set_inputs(_plugin_insert->input_streams()); + _splitting_icon.set_outputs(_plugin_insert->output_streams()); + + if (_plugin_insert->splitting () || ( + _plugin_insert->input_streams().n_midi() == 0 + && _plugin_insert->input_streams().n_audio() < _plugin_insert->output_streams().n_audio() + ) + ) + { _splitting_icon.show (); + _splitting_icon.queue_draw(); } else { _splitting_icon.hide (); } @@ -676,29 +684,53 @@ PluginInsertProcessorEntry::SplittingIcon::on_expose_event (GdkEventExpose* ev) Gdk::Color const fg = get_style()->get_fg (STATE_NORMAL); cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ()); - const float si_l = rintf(width * 0.2) + .5f; - const float si_c = rintf(width * 0.5) + .5f; - const float si_r = rintf(width * 0.8) + .5f; + const uint32_t inputs = _inputs.n_audio(); + const uint32_t outputs = _outputs.n_audio(); + const float si_m = rintf(height * 0.5) + .5f; - cairo_move_to (cr, si_l, height); - cairo_line_to (cr, si_l, si_m); - cairo_line_to (cr, si_r, si_m); - cairo_line_to (cr, si_r, height); - cairo_stroke (cr); + if (inputs == 1) { + const float si_l = rintf(width * 0.2) + .5f; + const float si_c = rintf(width * 0.5) + .5f; + const float si_r = rintf(width * 0.8) + .5f; - cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); - - for (uint32_t i = 2; i < _branches; ++i) { - const float si_b = rintf(width * (.2f + .6f * (i - 1.f) / (_branches - 1.f))) + .5f; - cairo_move_to (cr, si_b, height); - cairo_line_to (cr, si_b, si_m); + cairo_move_to (cr, si_l, height); + cairo_line_to (cr, si_l, si_m); + cairo_line_to (cr, si_r, si_m); + cairo_line_to (cr, si_r, height); cairo_stroke (cr); - } - cairo_move_to (cr, si_c, si_m); - cairo_line_to (cr, si_c, 0); - cairo_stroke (cr); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); + + const uint32_t outputs = _outputs.n_audio(); + for (uint32_t i = 2; i < outputs; ++i) { + const float si_b = rintf(width * (.2f + .6f * (i - 1.f) / (outputs - 1.f))) + .5f; + cairo_move_to (cr, si_b, height); + cairo_line_to (cr, si_b, si_m); + cairo_stroke (cr); + } + + cairo_move_to (cr, si_c, si_m); + cairo_line_to (cr, si_c, 0); + cairo_stroke (cr); + } else { + cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); + for (uint32_t i = 0 ; i < outputs; ++i) { + const float si_x = rintf(width * (.2f + .6f * i / (outputs - 1.f))) + .5f; + if (i < inputs) { + cairo_move_to (cr, si_x, height); + cairo_line_to (cr, si_x, 0); + cairo_stroke (cr); + } else { + cairo_move_to (cr, si_x, si_m); + cairo_line_to (cr, si_x, height); + cairo_stroke (cr); + cairo_move_to (cr, si_x+4, si_m); + cairo_line_to (cr, si_x-4, si_m); + cairo_stroke (cr); + } + } + } return true; } diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h index cacb5be77c..6aed08d17e 100644 --- a/gtk2_ardour/processor_box.h +++ b/gtk2_ardour/processor_box.h @@ -225,11 +225,16 @@ private: class SplittingIcon : public Gtk::DrawingArea { public: - SplittingIcon() { _branches = 2; } - void set_branches(uint32_t const branches) { _branches = branches; } + SplittingIcon() { + _inputs = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1); + _outputs = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 2); + } + void set_inputs(ARDOUR::ChanCount const inputs) { _inputs = inputs; } + void set_outputs(ARDOUR::ChanCount const outputs) { _outputs = outputs; } private: bool on_expose_event (GdkEventExpose *); - uint32_t _branches; + ARDOUR::ChanCount _inputs; + ARDOUR::ChanCount _outputs; }; boost::shared_ptr _plugin_insert; diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index a1b9c5a685..7d7e2e7269 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -122,8 +122,7 @@ class PluginInsert : public Processor } PBD::Signal2 AnalysisDataGathered; - /** Emitted when the return value of splitting () has changed */ - PBD::Signal0 SplittingChanged; + PBD::Signal0 PluginIoReConfigure; /** Enumeration of the ways in which we can match our insert's * IO to that of the plugin(s). diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 473040d812..c25f8962ac 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -650,6 +650,8 @@ bool PluginInsert::configure_io (ChanCount in, ChanCount out) { Match old_match = _match; + ChanCount old_in = input_streams (); + ChanCount old_out = output_streams (); /* set the matching method and number of plugins that we will use to meet this configuration */ _match = private_can_support_io_configuration (in, out); @@ -657,9 +659,12 @@ PluginInsert::configure_io (ChanCount in, ChanCount out) return false; } - /* a signal needs emitting if we start or stop splitting */ - if (old_match.method != _match.method && (old_match.method == Split || _match.method == Split)) { - SplittingChanged (); /* EMIT SIGNAL */ + if ( (old_match.method != _match.method && (old_match.method == Split || _match.method == Split)) + || old_in != in + || old_out != out + ) + { + PluginIoReConfigure (); /* EMIT SIGNAL */ } /* configure plugins */