diff options
author | Robin Gareus <robin@gareus.org> | 2020-04-02 19:55:33 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-04-02 20:27:51 +0200 |
commit | 14f15ca1e9526bde2db75d502c8290ac5d40db69 (patch) | |
tree | 36c6002a25b575cb18ae57b3cac3b951c0655b29 /gtk2_ardour/route_ui.cc | |
parent | f0b25a776be955903dd0589720ce521990d89db5 (diff) |
Move RouteUI::fan_out to Mixer_UI
The previous version had various issues, in particular
when creating Tracks with an instrument, the RouteUI was not
available when the signal was emitted (likely caused by recent
ee-work of Audio+MIDI and Tape track removal).
However as side-effect fanned-out tracks/busses may now
be ordered before the new instrument route.
This also fixes an edge case of multiple fan-out in case
there is more than one RouteUI instance (mixer, editor-mixer,
meter-bridge).
Diffstat (limited to 'gtk2_ardour/route_ui.cc')
-rw-r--r-- | gtk2_ardour/route_ui.cc | 105 |
1 files changed, 1 insertions, 104 deletions
diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index b7b2c88faf..0d7110f87d 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -2315,110 +2315,7 @@ RouteUI::manage_pins () void RouteUI::fan_out (bool to_busses, bool group) { - if (!ARDOUR_UI_UTILS::engine_is_running ()) { - return; - } - - DisplaySuspender ds; - boost::shared_ptr<ARDOUR::Route> route = _route; - 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; - } - -#define BUSNAME pd.group_name + "(" + route->name () + ")" - - /* count busses and channels/bus */ - 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 = BUSNAME; - 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); - - boost::shared_ptr<AutomationControl> msac = route->master_send_enable_controllable (); - if (msac) { - msac->start_touch (msac->session().transport_sample()); - msac->set_value (0, PBD::Controllable::NoGroup); - } - - RouteList to_group; - for (uint32_t p = 0; p < n_outputs; ++p) { - const Plugin::IOPortDescription& pd (plugin->describe_io_port (DataType::AUDIO, false, p)); - std::string bn = BUSNAME; - boost::shared_ptr<Route> r = _session->route_by_name (bn); - if (!r) { - try { - if (to_busses) { - RouteList rl = _session->new_audio_route (busnames[bn], outputs, NULL, 1, bn, PresentationInfo::AudioBus, PresentationInfo::max_order); - r = rl.front (); - assert (r); - } else { - list<boost::shared_ptr<AudioTrack> > tl = - _session->new_audio_track (busnames[bn], outputs, NULL, 1, bn, PresentationInfo::max_order, Normal); - r = tl.front (); - assert (r); - - boost::shared_ptr<ControlList> cl (new ControlList); - cl->push_back (r->monitoring_control ()); - _session->set_controls (cl, (double) MonitorInput, Controllable::NoGroup); - } - } catch (...) { - if (!to_group.empty()) { - boost::shared_ptr<RouteList> rl (&to_group); - _session->remove_routes (rl); - } - return; - } - r->input ()->disconnect (this); - } - to_group.push_back (r); - route->output ()->audio (p)->connect (r->input ()->audio (pd.group_channel).get()); - } -#undef BUSNAME - - if (group) { - RouteGroup* rg = NULL; - const std::list<RouteGroup*>& rgs (_session->route_groups ()); - for (std::list<RouteGroup*>::const_iterator i = rgs.begin (); i != rgs.end (); ++i) { - if ((*i)->name () == pi->name ()) { - rg = *i; - break; - } - } - if (!rg) { - rg = new RouteGroup (*_session, pi->name ()); - _session->add_route_group (rg); - rg->set_gain (false); - } - - GroupTabs::set_group_color (rg, route->presentation_info().color()); - for (RouteList::const_iterator i = to_group.begin(); i != to_group.end(); ++i) { - rg->add (*i); - } - } + Mixer_UI::instance()->fan_out (_route, to_busses, group); } bool |