2 * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3 * Copyright (C) 2011 Paul Davis
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include <boost/algorithm/string.hpp>
22 #include <gtkmm/table.h>
23 #include <gtkmm/frame.h>
24 #include <gtkmm/box.h>
25 #include <gtkmm/label.h>
27 #include "pbd/replace_all.h"
29 #include "gtkmm2ext/utils.h"
30 #include "gtkmm2ext/rgb_macros.h"
32 #include "ardour/audioengine.h"
33 #include "ardour/plugin.h"
34 #include "ardour/port.h"
35 #include "ardour/profile.h"
36 #include "ardour/session.h"
38 #include "plugin_pin_dialog.h"
39 #include "gui_thread.h"
41 #include "ui_config.h"
45 using namespace ARDOUR;
49 using namespace Gtkmm2ext;
51 PluginPinDialog::PluginPinDialog (boost::shared_ptr<ARDOUR::PluginInsert> pi)
52 : ArdourWindow (string_compose (_("Pin Configuration: %1"), pi->name ()))
53 , _set_config (_("Configure"), ArdourButton::led_default_elements)
54 , _tgl_sidechain (_("Side Chain"), ArdourButton::led_default_elements)
55 , _add_plugin (_("+"))
56 , _del_plugin (_("-"))
57 , _add_output_audio (_("+"))
58 , _del_output_audio (_("-"))
59 , _add_output_midi (_("+"))
60 , _del_output_midi (_("-"))
61 , _add_sc_audio (_("Audio"))
62 , _add_sc_midi (_("MIDI"))
74 , _position_valid (false)
75 , _ignore_updates (false)
76 , _sidechain_selector (0)
79 assert (pi->owner ()); // Route
81 _pi->PluginIoReConfigure.connect (
82 _plugin_connections, invalidator (*this), boost::bind (&PluginPinDialog::plugin_reconfigured, this), gui_context ()
85 _pi->PluginMapChanged.connect (
86 _plugin_connections, invalidator (*this), boost::bind (&PluginPinDialog::plugin_reconfigured, this), gui_context ()
89 _pi->PluginConfigChanged.connect (
90 _plugin_connections, invalidator (*this), boost::bind (&PluginPinDialog::plugin_reconfigured, this), gui_context ()
93 _pin_box_size = 2 * ceil (max (8., 10. * UIConfiguration::instance ().get_ui_scale ()) * .5);
94 _margin_x = 2 * ceil (max (24., 28. * UIConfiguration::instance ().get_ui_scale ()) * .5);
95 _margin_y = 2 * ceil (max (36., 40. * UIConfiguration::instance ().get_ui_scale ()) * .5);
97 _tgl_sidechain.set_name ("pinrouting sidechain");
98 _set_config.set_name ("pinrouting custom");
100 Menu_Helpers::MenuList& citems = reset_menu.items();
101 reset_menu.set_name ("ArdourContextMenu");
103 citems.push_back (Menu_Helpers::MenuElem (_("Reset"), sigc::mem_fun (*this, &PluginPinDialog::reset_mapping)));
105 _pm_size_group = SizeGroup::create (SIZE_GROUP_BOTH);
106 _add_plugin.set_tweaks (ArdourButton::Square);
107 _del_plugin.set_tweaks (ArdourButton::Square);
108 _pm_size_group->add_widget (_add_plugin);
109 _pm_size_group->add_widget (_del_plugin);
110 _pm_size_group->add_widget (_add_output_audio);
111 _pm_size_group->add_widget (_del_output_audio);
112 _pm_size_group->add_widget (_add_output_midi);
113 _pm_size_group->add_widget (_del_output_midi);
118 VBox* tl = manage (new VBox ());
119 tl->set_border_width (2);
122 VBox* tr = manage (new VBox ());
123 tr->set_border_width (2);
127 tl->pack_start (_set_config, false, false);
128 tl->pack_start (*manage (new Label ("")), true, true); // invisible separator
130 box = manage (new HBox ());
131 box->set_border_width (2);
132 box->pack_start (_add_plugin, true, false);
133 box->pack_start (_del_plugin, true, false);
134 f = manage (new Frame());
135 f->set_label (_("Instances"));
137 tl->pack_start (*f, false, false);
139 box = manage (new HBox ());
140 box->set_border_width (2);
141 box->pack_start (_add_output_audio, true, false);
142 box->pack_start (_del_output_audio, true, false);
143 f = manage (new Frame());
144 f->set_label (_("Audio Out"));
146 tl->pack_start (*f, false, false);
148 box = manage (new HBox ());
149 box->set_border_width (2);
150 box->pack_start (_add_output_midi, true, false);
151 box->pack_start (_del_output_midi, true, false);
152 f = manage (new Frame());
153 f->set_label (_("MIDI Out"));
155 tl->pack_start (*f, false, false);
159 _sidechain_tbl = manage (new Gtk::Table ());
160 _sidechain_tbl->set_spacings (2);
162 tr->pack_start (_tgl_sidechain, false, false);
163 tr->pack_start (*_sidechain_tbl, true, true);
165 box = manage (new VBox ());
166 box->set_border_width (2);
167 box->set_spacing (2);
168 box->pack_start (_add_sc_audio, false, false);
169 box->pack_start (_add_sc_midi , false, false);
170 f = manage (new Frame());
171 f->set_label (_("Add Sidechain Input"));
174 tr->pack_start (*f, false, false);
177 HBox* hbox = manage (new HBox ());
178 hbox->set_spacing (4);
179 hbox->pack_start (*tl, false, false);
180 hbox->pack_start (darea, true, true);
181 hbox->pack_start (*tr, false, false);
183 VBox* vbox = manage (new VBox ());
184 vbox->pack_start (*hbox, true, true);
185 set_border_width (4);
189 plugin_reconfigured ();
191 darea.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
192 darea.signal_size_request ().connect (sigc::mem_fun (*this, &PluginPinDialog::darea_size_request));
193 darea.signal_size_allocate ().connect (sigc::mem_fun (*this, &PluginPinDialog::darea_size_allocate));
194 darea.signal_expose_event ().connect (sigc::mem_fun (*this, &PluginPinDialog::darea_expose_event));
195 darea.signal_button_press_event ().connect (sigc::mem_fun (*this, &PluginPinDialog::darea_button_press_event));
196 darea.signal_button_release_event ().connect (sigc::mem_fun (*this, &PluginPinDialog::darea_button_release_event));
197 darea.signal_motion_notify_event ().connect (sigc::mem_fun (*this, &PluginPinDialog::darea_motion_notify_event));
199 _tgl_sidechain.signal_clicked.connect (sigc::mem_fun (*this, &PluginPinDialog::toggle_sidechain));
201 _set_config.signal_clicked.connect (sigc::mem_fun (*this, &PluginPinDialog::reset_configuration));
202 _add_plugin.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::add_remove_plugin_clicked), true));
203 _del_plugin.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::add_remove_plugin_clicked), false));
205 _add_output_audio.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::add_remove_port_clicked), true, DataType::AUDIO));
206 _del_output_audio.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::add_remove_port_clicked), false, DataType::AUDIO));
207 _add_output_midi.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::add_remove_port_clicked), true, DataType::MIDI));
208 _del_output_midi.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::add_remove_port_clicked), false, DataType::MIDI));
209 _add_sc_audio.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::add_sidechain_port), DataType::AUDIO));
210 _add_sc_midi.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::add_sidechain_port), DataType::MIDI));
212 AudioEngine::instance()->PortConnectedOrDisconnected.connect (
213 _io_connection, invalidator (*this), boost::bind (&PluginPinDialog::port_connected_or_disconnected, this, _1, _3), gui_context ()
217 PluginPinDialog::~PluginPinDialog ()
219 delete _sidechain_selector;
223 PluginPinDialog::plugin_reconfigured ()
225 ENSURE_GUI_THREAD (*this, &PluginPinDialog::plugin_reconfigured);
226 if (_ignore_updates) {
229 _n_plugins = _pi->get_count ();
230 _pi->configured_io (_in, _out);
231 _ins = _pi->internal_streams (); // with sidechain
232 _sinks = _pi->natural_input_streams ();
233 _sources = _pi->natural_output_streams ();
235 _tgl_sidechain.set_active (_pi->has_sidechain ());
236 _add_sc_audio.set_sensitive (_pi->has_sidechain ());
237 _add_sc_midi.set_sensitive (_pi->has_sidechain ());
239 if (_pi->custom_cfg ()) {
240 _set_config.set_active (true);
241 _add_plugin.set_sensitive (true);
242 _add_output_audio.set_sensitive (true);
243 _add_output_midi.set_sensitive (true);
244 _del_plugin.set_sensitive (_n_plugins > 1);
245 _del_output_audio.set_sensitive (_out.n_audio () > 0 && _out.n_total () > 1);
246 _del_output_midi.set_sensitive (_out.n_midi () > 0 && _out.n_total () > 1);
248 _set_config.set_active (false);
249 _add_plugin.set_sensitive (false);
250 _add_output_audio.set_sensitive (false);
251 _add_output_midi.set_sensitive (false);
252 _del_plugin.set_sensitive (false);
253 _del_output_audio.set_sensitive (false);
254 _del_output_midi.set_sensitive (false);
257 if (!_pi->has_sidechain () && _sidechain_selector) {
258 delete _sidechain_selector;
259 _sidechain_selector = 0;
262 refill_sidechain_table ();
264 /* update elements */
273 _n_inputs = _n_sidechains = 0;
275 for (uint32_t i = 0; i < _ins.n_total (); ++i) {
276 DataType dt = i < _ins.n_midi () ? DataType::MIDI : DataType::AUDIO;
277 uint32_t id = dt == DataType::MIDI ? i : i - _ins.n_midi ();
278 bool sidechain = id >= _in.get (dt) ? true : false;
285 CtrlWidget cw (CtrlWidget ("", Input, dt, id, 0, sidechain));
286 _elements.push_back (cw);
289 for (uint32_t i = 0; i < _out.n_total (); ++i) {
290 int id = (i < _out.n_midi ()) ? i : i - _out.n_midi ();
291 _elements.push_back (CtrlWidget ("", Output, (i < _out.n_midi () ? DataType::MIDI : DataType::AUDIO), id));
294 for (uint32_t n = 0; n < _n_plugins; ++n) {
295 boost::shared_ptr<Plugin> plugin = _pi->plugin (n);
296 for (uint32_t i = 0; i < _sinks.n_total (); ++i) {
297 DataType dt (i < _sinks.n_midi () ? DataType::MIDI : DataType::AUDIO);
298 int idx = (dt == DataType::MIDI) ? i : i - _sinks.n_midi ();
299 const Plugin::IOPortDescription& iod (plugin->describe_io_port (dt, true, idx));
300 CtrlWidget cw (CtrlWidget (iod.name, Sink, dt, idx, n, iod.is_sidechain));
301 _elements.push_back (cw);
303 for (uint32_t i = 0; i < _sources.n_total (); ++i) {
304 DataType dt (i < _sources.n_midi () ? DataType::MIDI : DataType::AUDIO);
305 int idx = (dt == DataType::MIDI) ? i : i - _sources.n_midi ();
306 const Plugin::IOPortDescription& iod (plugin->describe_io_port (dt, false, idx));
307 _elements.push_back (CtrlWidget (iod.name, Source, dt, idx, n));
311 /* calc minimum size */
312 const uint32_t max_ports = std::max (_ins.n_total (), _out.n_total ());
313 const uint32_t max_pins = std::max ((_sinks * _n_plugins).n_total (), (_sources * _n_plugins).n_total ());
314 uint32_t min_width = std::max (25 * max_ports, (uint32_t)(20 + _pin_box_size) * max_pins);
315 min_width = std::max (min_width, (uint32_t)ceilf (_margin_y * .45 * _n_plugins * 16. / 9.)); // 16 : 9 aspect
316 min_width = std::max ((uint32_t)300, min_width);
318 min_width = 50 + 10 * ceilf (min_width / 10.f);
320 uint32_t min_height = 3.5 * _margin_y + 2 * (_n_sidechains + 1) * _pin_box_size;
321 min_height = std::max ((uint32_t)200, min_height);
322 min_height = 4 * ceilf (min_height / 4.f);
324 if (min_width != _min_width || min_height != _min_height) {
325 _min_width = min_width;
326 _min_height = min_height;
327 darea.queue_resize ();
330 _position_valid = false;
335 PluginPinDialog::refill_sidechain_table ()
337 Table_Helpers::TableList& kids = _sidechain_tbl->children ();
338 for (Table_Helpers::TableList::iterator i = kids.begin (); i != kids.end ();) {
341 _sidechain_tbl->resize (1, 1);
342 if (!_pi->has_sidechain () && _sidechain_selector) {
345 boost::shared_ptr<IO> io = _pi->sidechain_input ();
351 PortSet& p (io->ports ());
352 bool can_remove = p.num_ports () > 1;
353 for (PortSet::iterator i = p.begin (DataType::MIDI); i != p.end (DataType::MIDI); ++i, ++r) {
354 add_port_to_table (*i, r, can_remove);
356 for (PortSet::iterator i = p.begin (DataType::AUDIO); i != p.end (DataType::AUDIO); ++i, ++r) {
357 add_port_to_table (*i, r, can_remove);
359 _sidechain_tbl->show_all ();
363 PluginPinDialog::add_port_to_table (boost::shared_ptr<Port> p, uint32_t r, bool can_remove)
366 std::string tip = p->name ();
367 std::vector<std::string> cns;
368 p->get_connections (cns);
370 // TODO proper labels, see MixerStrip::update_io_button()
371 if (cns.size () == 0) {
373 } else if (cns.size () > 1) {
377 string lpn (PROGRAM_NAME);
378 boost::to_lower (lpn);
379 std::string program_port_prefix = lpn + ":"; // e.g. "ardour:"
383 if (lbl.find ("system:capture_") == 0) {
384 lbl = AudioEngine::instance ()->get_pretty_name_by_name (lbl);
386 lbl = cns[0].substr (15);
388 } else if (lbl.find("system:midi_capture_") == 0) {
389 lbl = AudioEngine::instance ()->get_pretty_name_by_name (lbl);
391 // "system:midi_capture_123" -> "123"
392 lbl = "M " + cns[0].substr (20);
394 } else if (lbl.find (program_port_prefix) == 0) {
395 lbl = lbl.substr (program_port_prefix.size());
398 for (std::vector<std::string>::const_iterator i = cns.begin(); i != cns.end(); ++i) {
402 replace_all (lbl, "_", " ");
404 ArdourButton *pb = manage (new ArdourButton (lbl));
405 pb->set_text_ellipsize (Pango::ELLIPSIZE_MIDDLE);
406 pb->set_layout_ellipsize_width (108 * PANGO_SCALE);
407 ARDOUR_UI_UTILS::set_tooltip (*pb, tip);
408 _sidechain_tbl->attach (*pb, 0, 1, r, r +1 , EXPAND|FILL, SHRINK);
410 pb->signal_button_press_event ().connect (sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::sc_input_press), boost::weak_ptr<Port> (p)), false);
411 pb->signal_button_release_event ().connect (sigc::mem_fun (*this, &PluginPinDialog::sc_input_release), false);
413 pb = manage (new ArdourButton ("-"));
414 _sidechain_tbl->attach (*pb, 1, 2, r, r +1 , FILL, SHRINK);
416 pb->signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::remove_port), boost::weak_ptr<Port> (p)));
418 pb->set_sensitive (false);
423 PluginPinDialog::update_element_pos ()
426 _innerwidth = _width - 2. * _margin_x;
428 const double yc = rint (_height * .5);
429 const double bxh2 = rint (_margin_y * .45); // TODO grow?
430 const double bxw = rint ((_innerwidth * .95) / ((_n_plugins) + .2 * (_n_plugins - 1)));
431 const double bxw2 = rint (bxw * .5);
432 const double y_in = _margin_y;
433 const double y_out = _height - _margin_y;
438 const double dx = _pin_box_size * .5;
441 for (CtrlElemList::iterator i = _elements.begin (); i != _elements.end (); ++i) {
445 i->x = _innerwidth + _margin_x - dx;
446 i->y = y_in + (sc_cnt + .5) * _pin_box_size;
447 i->h = _pin_box_size;
448 i->w = 1.5 * _pin_box_size;
451 uint32_t idx = i->e->id;
452 if (i->e->dt == DataType::AUDIO) { idx += _in.n_midi (); }
453 i->x = rint ((idx + 1) * _width / (1. + _n_inputs)) - 0.5 - dx;
454 i->w = _pin_box_size;
455 i->h = 1.5 * _pin_box_size;
461 uint32_t idx = i->e->id;
462 if (i->e->dt == DataType::AUDIO) { idx += _out.n_midi (); }
463 i->x = rint ((idx + 1) * _width / (1. + _out.n_total ())) - 0.5 - dx;
465 i->w = _pin_box_size;
466 i->h = 1.5 * _pin_box_size;
471 uint32_t idx = i->e->id;
472 if (i->e->dt == DataType::AUDIO) { idx += _sinks.n_midi (); }
473 const double x0 = rint ((i->e->ip + .5) * _innerwidth / (double)(_n_plugins)) - .5 - bxw2;
474 i->x = _margin_x + rint (x0 + (idx + 1) * bxw / (1. + _sinks.n_total ())) - .5 - dx;
475 i->y = yc - bxh2 - dx;
476 i->w = _pin_box_size;
477 i->h = _pin_box_size;
482 uint32_t idx = i->e->id;
483 if (i->e->dt == DataType::AUDIO) { idx += _sources.n_midi (); }
484 const double x0 = rint ((i->e->ip + .5) * _innerwidth / (double)(_n_plugins)) - .5 - bxw2;
485 i->x = _margin_x + rint (x0 + (idx + 1) * bxw / (1. + _sources.n_total ())) - .5 - dx;
486 i->y = yc + bxh2 - dx;
487 i->w = _pin_box_size;
488 i->h = _pin_box_size;
496 PluginPinDialog::set_color (cairo_t* cr, bool midi)
498 // see also gtk2_ardour/processor_box.cc
499 static const uint32_t audio_port_color = 0x4A8A0EFF; // Green
500 static const uint32_t midi_port_color = 0x960909FF; //Red
503 cairo_set_source_rgb (cr,
504 UINT_RGBA_R_FLT (midi_port_color),
505 UINT_RGBA_G_FLT (midi_port_color),
506 UINT_RGBA_B_FLT (midi_port_color));
508 cairo_set_source_rgb (cr,
509 UINT_RGBA_R_FLT (audio_port_color),
510 UINT_RGBA_G_FLT (audio_port_color),
511 UINT_RGBA_B_FLT (audio_port_color));
516 PluginPinDialog::draw_io_pin (cairo_t* cr, const CtrlWidget& w)
519 const double dy = w.h * .5;
520 const double dx = w.w - dy;
521 cairo_move_to (cr, w.x, w.y + dy);
522 cairo_rel_line_to (cr, dy, -dy);
523 cairo_rel_line_to (cr, dx, 0);
524 cairo_rel_line_to (cr, 0, w.h);
525 cairo_rel_line_to (cr, -dx, 0);
527 const double dir = (w.e->ct == Input) ? 1 : -1;
528 const double dx = w.w * .5;
529 const double dy = w.h - dx;
531 cairo_move_to (cr, w.x + dx, w.y + ((w.e->ct == Input) ? w.h : 0));
532 cairo_rel_line_to (cr, -dx, -dx * dir);
533 cairo_rel_line_to (cr, 0., -dy * dir);
534 cairo_rel_line_to (cr, 2. * dx, 0.);
535 cairo_rel_line_to (cr, 0., dy * dir);
537 cairo_close_path (cr);
539 cairo_set_line_width (cr, 1.0);
540 cairo_set_source_rgb (cr, 0, 0, 0);
541 cairo_stroke_preserve (cr);
543 set_color (cr, w.e->dt == DataType::MIDI);
546 assert (w.e->ct == Input);
547 cairo_fill_preserve (cr);
548 cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.4);
551 if (w.e == _selection || w.e == _actor) {
552 cairo_fill_preserve (cr);
553 cairo_set_source_rgba (cr, 0.9, 0.9, 1.0, 0.6);
554 } else if (w.prelight) {
555 cairo_fill_preserve (cr);
556 cairo_set_source_rgba (cr, 0.9, 0.9, 0.9, 0.3);
562 PluginPinDialog::draw_plugin_pin (cairo_t* cr, const CtrlWidget& w)
564 const double dx = w.w * .5;
565 const double dy = w.h * .5;
567 cairo_move_to (cr, w.x + dx, w.y);
568 cairo_rel_line_to (cr, -dx, dy);
569 cairo_rel_line_to (cr, dx, dy);
570 cairo_rel_line_to (cr, dx, -dy);
571 cairo_close_path (cr);
573 cairo_set_line_width (cr, 1.0);
574 cairo_set_source_rgb (cr, 0, 0, 0);
575 cairo_stroke_preserve (cr);
577 set_color (cr, w.e->dt == DataType::MIDI);
580 assert (w.e->ct == Sink);
581 cairo_fill_preserve (cr);
582 cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.4);
585 if (w.e == _selection || w.e == _actor) {
586 cairo_fill_preserve (cr);
587 cairo_set_source_rgba (cr, 0.9, 0.9, 1.0, 0.6);
588 } else if (w.prelight) {
589 cairo_fill_preserve (cr);
590 cairo_set_source_rgba (cr, 0.9, 0.9, 0.9, 0.3);
594 if ((w.prelight || w.e == _selection) && !w.name.empty()) {
597 Glib::RefPtr<Pango::Layout> layout;
598 layout = Pango::Layout::create (get_pango_context ());
599 layout->set_text (w.name);
600 layout->get_pixel_size (text_width, text_height);
602 rounded_rectangle (cr, w.x + dx - .5 * text_width - 2, w.y - text_height - 2, text_width + 4, text_height + 2, 7);
603 cairo_set_source_rgba (cr, 0, 0, 0, .5);
606 cairo_move_to (cr, w.x + dx - .5 * text_width, w.y - text_height - 1);
607 cairo_set_source_rgba (cr, 1., 1., 1., 1.);
608 pango_cairo_show_layout (cr, layout->gobj ());
613 PluginPinDialog::pin_x_pos (uint32_t i, double x0, double width, uint32_t n_total, uint32_t n_midi, bool midi)
615 if (!midi) { i += n_midi; }
616 return rint (x0 + (i + 1) * width / (1. + n_total)) - .5;
619 const PluginPinDialog::CtrlWidget&
620 PluginPinDialog::get_io_ctrl (CtrlType ct, DataType dt, uint32_t id, uint32_t ip) const
622 for (CtrlElemList::const_iterator i = _elements.begin (); i != _elements.end (); ++i) {
623 if (i->e->ct == ct && i->e->dt == dt && i->e->id == id && i->e->ip == ip) {
628 fatal << string_compose (_("programming error: %1"),
629 X_("Invalid Plugin I/O Port."))
631 abort (); /*NOTREACHED*/
632 static CtrlWidget screw_old_compilers ("", Input, DataType::NIL, 0);
633 return screw_old_compilers;
637 PluginPinDialog::edge_coordinates (const CtrlWidget& w, double &x, double &y)
665 PluginPinDialog::draw_connection (cairo_t* cr, double x0, double x1, double y0, double y1, bool midi, bool horiz, bool dashed)
667 const double bz = 2 * _pin_box_size;
668 const double bc = (dashed && x0 == x1) ? 1.25 * _pin_box_size : 0;
670 cairo_move_to (cr, x0, y0);
672 cairo_curve_to (cr, x0 - bz, y0 + bc, x1 - bc, y1 - bz, x1, y1);
674 cairo_curve_to (cr, x0 - bc, y0 + bz, x1 - bc, y1 - bz, x1, y1);
676 cairo_set_line_width (cr, 3.0);
677 cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
678 cairo_set_source_rgb (cr, 1, 0, 0);
680 const double dashes[] = { 5, 7 };
681 cairo_set_dash (cr, dashes, 2, 0);
683 set_color (cr, midi);
686 cairo_set_dash (cr, 0, 0, 0);
691 PluginPinDialog::draw_connection (cairo_t* cr, const CtrlWidget& w0, const CtrlWidget& w1, bool dashed)
693 double x0, x1, y0, y1;
694 edge_coordinates (w0, x0, y0);
695 edge_coordinates (w1, x1, y1);
696 assert (w0.e->dt == w1.e->dt);
697 draw_connection (cr, x0, x1, y0, y1, w0.e->dt == DataType::MIDI, w0.e->sc, dashed);
702 PluginPinDialog::darea_expose_event (GdkEventExpose* ev)
704 Gtk::Allocation a = darea.get_allocation ();
705 double const width = a.get_width ();
706 double const height = a.get_height ();
708 if (!_position_valid) {
711 update_element_pos ();
712 _position_valid = true;
715 cairo_t* cr = gdk_cairo_create (darea.get_window ()->gobj ());
716 cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
719 Gdk::Color const bg = get_style ()->get_bg (STATE_NORMAL);
720 cairo_set_source_rgb (cr, bg.get_red_p (), bg.get_green_p (), bg.get_blue_p ());
721 cairo_rectangle (cr, 0, 0, width, height);
724 const double yc = rint (_height * .5);
727 rounded_rectangle (cr, _margin_x, _margin_y - _pin_box_size * .5, _innerwidth, _height - 2 * _margin_y + _pin_box_size, 7);
728 cairo_set_line_width (cr, 1.0);
729 cairo_set_source_rgb (cr, .1, .1, .3);
730 cairo_stroke_preserve (cr);
731 cairo_set_source_rgb (cr, .3, .3, .3);
734 /* draw midi-bypass (behind) */
735 if (_pi->has_midi_bypass ()) {
736 const CtrlWidget& cw0 = get_io_ctrl (Input, DataType::MIDI, 0);
737 const CtrlWidget& cw1 = get_io_ctrl (Output, DataType::MIDI, 0);
738 draw_connection (cr, cw0, cw1, true);
741 /* thru connections */
742 const ChanMapping::Mappings thru_map = _pi->thru_map ().mappings ();
743 for (ChanMapping::Mappings::const_iterator t = thru_map.begin (); t != thru_map.end (); ++t) {
744 for (ChanMapping::TypeMapping::const_iterator c = (*t).second.begin (); c != (*t).second.end () ; ++c) {
745 const CtrlWidget& cw0 = get_io_ctrl (Output, t->first, c->first);
746 const CtrlWidget& cw1 = get_io_ctrl (Input, t->first, c->second);
747 if (!(_dragging && cw1.e == _selection && cw0.e == _drag_dst)) {
748 draw_connection (cr, cw1, cw0, true);
754 Glib::RefPtr<Pango::Layout> layout;
755 layout = Pango::Layout::create (get_pango_context ());
757 layout->set_ellipsize (Pango::ELLIPSIZE_MIDDLE);
758 layout->set_width (_height * PANGO_SCALE);
763 layout->set_text (_route ()->name ());
764 layout->get_pixel_size (text_width, text_height);
766 cairo_move_to (cr, .5 * (_margin_x - text_height), .5 * (_height + text_width));
767 cairo_rotate (cr, M_PI * -.5);
768 cairo_set_source_rgba (cr, 1., 1., 1., 1.);
769 pango_cairo_show_layout (cr, layout->gobj ());
773 layout->set_width ((_innerwidth - 2 * _pin_box_size) * PANGO_SCALE);
774 layout->set_text (_pi->name ());
775 layout->get_pixel_size (text_width, text_height);
776 cairo_move_to (cr, _margin_x + _innerwidth - text_width - _pin_box_size * .5, _height - _margin_y - text_height);
777 cairo_set_source_rgba (cr, 1., 1., 1., 1.);
778 pango_cairo_show_layout (cr, layout->gobj ());
780 if (_pi->strict_io () && !Profile->get_mixbus ()) {
781 layout->set_text (_("Strict I/O"));
782 layout->get_pixel_size (text_width, text_height);
783 const double sx0 = _margin_x + .5 * (_innerwidth - text_width);
784 const double sy0 = _height - 3 - text_height;
786 rounded_rectangle (cr, sx0 - 2, sy0 - 1, text_width + 4, text_height + 2, 7);
787 cairo_set_source_rgba (cr, .4, .3, .1, 1.);
790 cairo_set_source_rgba (cr, 1., 1., 1., 1.);
791 cairo_move_to (cr, sx0, sy0);
792 cairo_set_source_rgba (cr, 1., 1., 1., 1.);
793 pango_cairo_show_layout (cr, layout->gobj ());
797 /* plugins & connection wires */
798 for (uint32_t i = 0; i < _n_plugins; ++i) {
799 double x0 = _margin_x + rint ((i + .5) * _innerwidth / (double)(_n_plugins)) - .5;
802 cairo_set_source_rgb (cr, .5, .5, .5);
803 rounded_rectangle (cr, x0 - _bxw2, yc - _bxh2, 2 * _bxw2, 2 * _bxh2, 7);
806 const ChanMapping::Mappings in_map = _pi->input_map (i).mappings ();
807 const ChanMapping::Mappings out_map = _pi->output_map (i).mappings ();
809 for (ChanMapping::Mappings::const_iterator t = in_map.begin (); t != in_map.end (); ++t) {
810 for (ChanMapping::TypeMapping::const_iterator c = (*t).second.begin (); c != (*t).second.end () ; ++c) {
811 const CtrlWidget& cw0 = get_io_ctrl (Input, t->first, c->second);
812 const CtrlWidget& cw1 = get_io_ctrl (Sink, t->first, c->first, i);
813 if (!(_dragging && cw0.e == _selection && cw1.e == _drag_dst)) {
814 draw_connection (cr, cw0, cw1);
819 for (ChanMapping::Mappings::const_iterator t = out_map.begin (); t != out_map.end (); ++t) {
820 for (ChanMapping::TypeMapping::const_iterator c = (*t).second.begin (); c != (*t).second.end () ; ++c) {
821 const CtrlWidget& cw0 = get_io_ctrl (Source, t->first, c->first, i);
822 const CtrlWidget& cw1 = get_io_ctrl (Output, t->first, c->second);
823 if (!(_dragging && cw0.e == _selection && cw1.e == _drag_dst)) {
824 draw_connection (cr, cw0, cw1);
831 for (CtrlElemList::const_iterator i = _elements.begin (); i != _elements.end (); ++i) {
835 draw_io_pin (cr, *i);
839 draw_plugin_pin (cr, *i);
845 CtrlWidget *drag_src = NULL;
847 for (CtrlElemList::iterator i = _elements.begin (); i != _elements.end (); ++i) {
848 if (i->e == _selection ) {
856 if (_selection->ct == Input || _selection->ct == Source) {
857 edge_coordinates (*drag_src, x0, y0);
858 draw_connection (cr, x0, _drag_x, y0, _drag_y,
859 _selection->dt == DataType::MIDI, _selection->sc);
861 edge_coordinates (*drag_src, x0, y0);
862 draw_connection (cr, _drag_x, x0, _drag_y, y0,
863 _selection->dt == DataType::MIDI, _selection->sc);
872 PluginPinDialog::darea_size_request (Gtk::Requisition* req)
874 req->width = _min_width;
875 req->height = _min_height;
879 PluginPinDialog::darea_size_allocate (Gtk::Allocation&)
881 _position_valid = false;
885 PluginPinDialog::drag_type_matches (const CtrlElem& e)
887 if (!_dragging || !_selection) {
890 if (_selection->dt != e->dt) {
893 if (_selection->ct == Input && e->ct == Sink) { return true; }
894 if (_selection->ct == Sink && e->ct == Input) { return true; }
895 if (_selection->ct == Output && e->ct == Source) { return true; }
896 if (_selection->ct == Source && e->ct == Output) { return true; }
897 if (_selection->ct == Input && e->ct == Output) { return true; }
898 if (_selection->ct == Output && e->ct == Input) { return true; }
903 PluginPinDialog::start_drag (const CtrlElem& e, double x, double y)
905 assert (_selection == e);
909 const ChanMapping& map (_pi->input_map (e->ip));
910 uint32_t idx = map.get (e->dt, e->id, &valid);
912 const CtrlWidget& cw = get_io_ctrl (Input, e->dt, idx, 0);
917 else if (e->ct == Output) {
918 for (uint32_t i = 0; i < _n_plugins; ++i) {
920 const ChanMapping& map (_pi->output_map (i));
921 uint32_t idx = map.get_src (e->dt, e->id, &valid);
923 const CtrlWidget& cw = get_io_ctrl (Source, e->dt, idx, i);
931 const ChanMapping& map (_pi->thru_map ());
932 uint32_t idx = map.get (e->dt, e->id, &valid);
934 const CtrlWidget& cw = get_io_ctrl (Input, e->dt, idx, 0);
946 PluginPinDialog::darea_motion_notify_event (GdkEventMotion* ev)
948 bool changed = false;
950 for (CtrlElemList::iterator i = _elements.begin (); i != _elements.end (); ++i) {
951 if (ev->x >= i->x && ev->x <= i->x + i->w
952 && ev->y >= i->y && ev->y <= i->y + i->h
953 && drag_type_matches (i->e))
955 if (!i->prelight) changed = true;
959 if (i->prelight) changed = true;
967 if (changed || _dragging) {
974 PluginPinDialog::darea_button_press_event (GdkEventButton* ev)
976 if (ev->type != GDK_BUTTON_PRESS) {
980 switch (ev->button) {
983 if (!_selection || (_selection && !_hover)) {
987 start_drag (_selection, ev->x, ev->y);
990 } else if (_selection && _hover && _selection != _hover) {
991 if (_selection->dt != _hover->dt) { _actor.reset (); }
992 else if (_selection->ct == Input && _hover->ct == Sink) { _actor = _hover; }
993 else if (_selection->ct == Sink && _hover->ct == Input) { _actor = _hover; }
994 else if (_selection->ct == Output && _hover->ct == Source) { _actor = _hover; }
995 else if (_selection->ct == Source && _hover->ct == Output) { _actor = _hover; }
996 else if (_selection->ct == Input && _hover->ct == Output) { _actor = _hover; }
997 else if (_selection->ct == Output && _hover->ct == Input) { _actor = _hover; }
1000 start_drag (_selection, ev->x, ev->y);
1002 darea.queue_draw ();
1003 } else if (_hover) {
1004 _selection = _hover;
1006 start_drag (_selection, ev->x, ev->y);
1011 if (_selection != _hover) {
1012 _selection = _hover;
1013 darea.queue_draw ();
1025 PluginPinDialog::darea_button_release_event (GdkEventButton* ev)
1027 if (_dragging && _selection && _drag_dst && _drag_dst == _hover) {
1028 // select click. (or re-connect same)
1029 assert (_selection != _hover);
1034 darea.queue_draw ();
1038 if (_dragging && _hover && _hover != _selection) {
1042 if (_hover == _actor && _actor && ev->button == 1) {
1043 assert (_selection);
1044 assert (_selection->dt == _actor->dt);
1046 assert (_dragging && _selection != _drag_dst);
1047 handle_disconnect (_drag_dst, true);
1049 if (_selection->ct == Input && _actor->ct == Sink) {
1050 handle_input_action (_actor, _selection);
1052 else if (_selection->ct == Sink && _actor->ct == Input) {
1053 handle_input_action (_selection, _actor);
1055 else if (_selection->ct == Output && _actor->ct == Source) {
1056 handle_output_action (_actor, _selection);
1058 else if (_selection->ct == Source && _actor->ct == Output) {
1059 handle_output_action (_selection, _actor);
1061 else if (_selection->ct == Input && _actor->ct == Output) {
1062 handle_thru_action (_actor, _selection);
1064 else if (_selection->ct == Output && _actor->ct == Input) {
1065 handle_thru_action (_selection, _actor);
1067 _selection.reset ();
1068 } else if (_hover == _selection && _selection && ev->button == 3) {
1069 handle_disconnect (_selection);
1070 } else if (!_hover && ev->button == 3) {
1071 reset_menu.popup (1, ev->time);
1074 if (_dragging && _hover != _selection) {
1075 _selection.reset ();
1080 darea.queue_draw ();
1085 PluginPinDialog::handle_input_action (const CtrlElem &s, const CtrlElem &i)
1087 const int pc = s->ip;
1089 ChanMapping in_map (_pi->input_map (pc));
1090 uint32_t idx = in_map.get (s->dt, s->id, &valid);
1092 if (valid && idx == i->id) {
1095 in_map.unset (s->dt, s->id);
1096 _pi->set_input_map (pc, in_map);
1098 plugin_reconfigured ();
1103 in_map.set (s->dt, s->id, i->id);
1104 _pi->set_input_map (pc, in_map);
1108 in_map.unset (s->dt, s->id);
1109 in_map.set (s->dt, s->id, i->id);
1110 _pi->set_input_map (pc, in_map);
1115 PluginPinDialog::disconnect_other_outputs (uint32_t skip_pc, DataType dt, uint32_t id)
1117 _ignore_updates = true;
1118 for (uint32_t n = 0; n < _n_plugins; ++n) {
1123 ChanMapping n_out_map (_pi->output_map (n));
1124 uint32_t idx = n_out_map.get_src (dt, id, &valid);
1126 n_out_map.unset (dt, idx);
1127 _pi->set_output_map (n, n_out_map);
1130 _ignore_updates = false;
1134 PluginPinDialog::disconnect_other_thru (DataType dt, uint32_t id)
1136 _ignore_updates = true;
1138 ChanMapping n_thru_map (_pi->thru_map ());
1139 n_thru_map.get (dt, id, &valid);
1141 n_thru_map.unset (dt, id);
1142 _pi->set_thru_map (n_thru_map);
1144 _ignore_updates = false;
1148 PluginPinDialog::handle_output_action (const CtrlElem &s, const CtrlElem &o)
1150 const uint32_t pc = s->ip;
1152 ChanMapping out_map (_pi->output_map (pc));
1153 uint32_t idx = out_map.get (s->dt, s->id, &valid);
1155 if (valid && idx == o->id) {
1158 out_map.unset (s->dt, s->id);
1159 _pi->set_output_map (pc, out_map);
1161 plugin_reconfigured ();
1165 // disconnect source
1166 disconnect_other_outputs (pc, s->dt, o->id);
1167 disconnect_other_thru (s->dt, o->id);
1168 out_map = _pi->output_map (pc); // re-read map
1170 out_map.unset (s->dt, s->id);
1172 idx = out_map.get_src (s->dt, o->id, &valid);
1174 out_map.unset (s->dt, idx);
1177 out_map.set (s->dt, s->id, o->id);
1178 _pi->set_output_map (pc, out_map);
1183 PluginPinDialog::handle_thru_action (const CtrlElem &o, const CtrlElem &i)
1186 ChanMapping thru_map (_pi->thru_map ());
1187 uint32_t idx = thru_map.get (o->dt, o->id, &valid);
1189 if (valid && idx == i->id) {
1191 thru_map.unset (o->dt, o->id);
1194 // disconnect other outputs first
1195 disconnect_other_outputs (UINT32_MAX, o->dt, o->id);
1196 disconnect_other_thru (o->dt, o->id);
1197 thru_map = _pi->thru_map (); // re-read map
1199 thru_map.set (o->dt, o->id, i->id);
1201 _pi->set_thru_map (thru_map);
1205 PluginPinDialog::handle_disconnect (const CtrlElem &e, bool no_signal)
1207 _ignore_updates = true;
1208 bool changed = false;
1214 ChanMapping n_thru_map (_pi->thru_map ());
1215 for (uint32_t i = 0; i < _sources.n_total (); ++i) {
1216 uint32_t idx = n_thru_map.get (e->dt, i, &valid);
1217 if (valid && idx == e->id) {
1218 n_thru_map.unset (e->dt, i);
1223 _pi->set_thru_map (n_thru_map);
1226 for (uint32_t n = 0; n < _n_plugins; ++n) {
1227 ChanMapping map (_pi->input_map (n));
1228 for (uint32_t i = 0; i < _sinks.n_total (); ++i) {
1229 uint32_t idx = map.get (e->dt, i, &valid);
1230 if (valid && idx == e->id) {
1231 map.unset (e->dt, i);
1235 _pi->set_input_map (n, map);
1240 ChanMapping map (_pi->input_map (e->ip));
1241 map.get (e->dt, e->id, &valid);
1243 map.unset (e->dt, e->id);
1244 _pi->set_input_map (e->ip, map);
1251 ChanMapping map (_pi->output_map (e->ip));
1252 map.get (e->dt, e->id, &valid);
1254 map.unset (e->dt, e->id);
1255 _pi->set_output_map (e->ip, map);
1261 for (uint32_t n = 0; n < _n_plugins; ++n) {
1262 ChanMapping map (_pi->output_map (n));
1263 for (uint32_t i = 0; i < _sources.n_total (); ++i) {
1264 uint32_t idx = map.get (e->dt, i, &valid);
1265 if (valid && idx == e->id) {
1266 map.unset (e->dt, i);
1271 _pi->set_output_map (n, map);
1275 ChanMapping n_thru_map (_pi->thru_map ());
1276 n_thru_map.get (e->dt, e->id, &valid);
1278 n_thru_map.unset (e->dt, e->id);
1280 _pi->set_thru_map (n_thru_map);
1285 _ignore_updates = false;
1286 if (changed && !no_signal) {
1287 plugin_reconfigured ();
1293 PluginPinDialog::toggle_sidechain ()
1295 if (_session && _session->actively_recording()) { return; }
1296 _route ()->add_remove_sidechain (_pi, !_pi->has_sidechain ());
1300 PluginPinDialog::connect_sidechain ()
1302 if (!_session) { return; }
1304 if (_sidechain_selector == 0) {
1305 _sidechain_selector = new IOSelectorWindow (_session, _pi->sidechain_input ());
1308 if (_sidechain_selector->is_visible ()) {
1309 _sidechain_selector->get_toplevel ()->get_window ()->raise ();
1311 _sidechain_selector->present ();
1316 PluginPinDialog::reset_configuration ()
1318 if (_set_config.get_active ()) {
1319 _route ()->reset_plugin_insert (_pi);
1321 _route ()->customize_plugin_insert (_pi, _n_plugins, _out);
1326 PluginPinDialog::reset_mapping ()
1332 PluginPinDialog::add_remove_plugin_clicked (bool add)
1334 if (_session && _session->actively_recording()) { return; }
1335 ChanCount out = _out;
1336 assert (add || _n_plugins > 0);
1337 _route ()->customize_plugin_insert (_pi, _n_plugins + (add ? 1 : -1), out);
1341 PluginPinDialog::add_remove_port_clicked (bool add, ARDOUR::DataType dt)
1343 if (_session && _session->actively_recording()) { return; }
1344 ChanCount out = _out;
1345 assert (add || out.get (dt) > 0);
1346 out.set (dt, out.get (dt) + (add ? 1 : -1));
1347 _route ()->customize_plugin_insert (_pi, _n_plugins, out);
1351 PluginPinDialog::add_sidechain_port (DataType dt)
1353 if (_session && _session->actively_recording()) { return; }
1354 boost::shared_ptr<IO> io = _pi->sidechain_input ();
1358 io->add_port ("", this, dt);
1362 PluginPinDialog::remove_port (boost::weak_ptr<ARDOUR::Port> wp)
1364 if (_session && _session->actively_recording()) { return; }
1365 boost::shared_ptr<ARDOUR::Port> p = wp.lock ();
1366 boost::shared_ptr<IO> io = _pi->sidechain_input ();
1370 io->remove_port (p, this);
1374 PluginPinDialog::disconnect_port (boost::weak_ptr<ARDOUR::Port> wp)
1376 if (_session && _session->actively_recording()) { return; }
1377 boost::shared_ptr<ARDOUR::Port> p = wp.lock ();
1378 boost::shared_ptr<IO> io = _pi->sidechain_input ();
1382 p->disconnect_all ();
1386 PluginPinDialog::connect_port (boost::weak_ptr<ARDOUR::Port> wp0, boost::weak_ptr<ARDOUR::Port> wp1)
1388 if (_session && _session->actively_recording()) { return; }
1389 boost::shared_ptr<ARDOUR::Port> p0 = wp0.lock ();
1390 boost::shared_ptr<ARDOUR::Port> p1 = wp1.lock ();
1391 boost::shared_ptr<IO> io = _pi->sidechain_input ();
1392 if (!io || !p0 || !p1) {
1395 _ignore_updates = true;
1396 p0->disconnect_all ();
1397 _ignore_updates = false;
1398 p0->connect (p1->name ());
1402 PluginPinDialog::sc_input_release (GdkEventButton *ev)
1404 if (_session && _session->actively_recording()) { return false; }
1405 if (ev->button == 3) {
1406 connect_sidechain ();
1411 struct RouteCompareByName {
1412 bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
1413 return a->name().compare (b->name()) < 0;
1418 PluginPinDialog::sc_input_press (GdkEventButton *ev, boost::weak_ptr<ARDOUR::Port> wp)
1420 using namespace Menu_Helpers;
1421 if (!_session || _session->actively_recording()) { return false; }
1422 if (!_session->engine().connected()) { return false; }
1424 if (ev->button == 1) {
1425 MenuList& citems = input_menu.items();
1426 input_menu.set_name ("ArdourContextMenu");
1429 boost::shared_ptr<Port> p = wp.lock ();
1430 if (p && p->connected ()) {
1431 citems.push_back (MenuElem (_("Disconnect"), sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::disconnect_port), wp)));
1432 citems.push_back (SeparatorElem());
1436 // TODO add system inputs, too ?!
1437 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
1438 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
1439 for (uint32_t j = 0; j < i->nchannels ().n_total (); ++j) {
1441 //maybe_add_bundle_to_input_menu (*i, current);
1445 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
1446 RouteList copy = *routes;
1447 copy.sort (RouteCompareByName ());
1449 for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
1450 added += maybe_add_route_to_input_menu (*i, p->type (), wp);
1454 citems.push_back (SeparatorElem());
1456 citems.push_back (MenuElem (_("Routing Grid"), sigc::mem_fun (*this, &PluginPinDialog::connect_sidechain)));
1457 input_menu.popup (1, ev->time);
1463 PluginPinDialog::maybe_add_route_to_input_menu (boost::shared_ptr<Route> r, DataType dt, boost::weak_ptr<Port> wp)
1466 using namespace Menu_Helpers;
1467 if (r->output () == _route()->output()) {
1471 if (_route ()->feeds_according_to_graph (r)) {
1475 MenuList& citems = input_menu.items();
1476 const IOVector& iov (r->all_outputs());
1478 for (IOVector::const_iterator o = iov.begin(); o != iov.end(); ++o) {
1479 boost::shared_ptr<IO> op = o->lock();
1483 PortSet& p (op->ports ());
1484 for (PortSet::iterator i = p.begin (dt); i != p.end (dt); ++i) {
1485 std::string n = i->name ();
1486 replace_all (n, "_", " ");
1487 citems.push_back (MenuElem (n, sigc::bind (sigc::mem_fun(*this, &PluginPinDialog::connect_port), wp, boost::weak_ptr<Port> (*i))));
1495 PluginPinDialog::port_connected_or_disconnected (boost::weak_ptr<ARDOUR::Port> w0, boost::weak_ptr<ARDOUR::Port> w1)
1497 boost::shared_ptr<Port> p0 = w0.lock ();
1498 boost::shared_ptr<Port> p1 = w1.lock ();
1500 boost::shared_ptr<IO> io = _pi->sidechain_input ();
1501 if (!io) { return; }
1503 if (p0 && io->has_port (p0)) {
1504 plugin_reconfigured ();
1506 else if (p1 && io->has_port (p1)) {
1507 plugin_reconfigured ();