From b8202431efa5e0f52a2d672e5cc4dcae9aa0bda7 Mon Sep 17 00:00:00 2001 From: Len Ovens Date: Fri, 8 May 2020 23:18:26 -0700 Subject: [PATCH] Add foldback bus dulication option Duplicates the bus and its sends and levels --- gtk2_ardour/foldback_strip.cc | 41 +++++++++++++++++++++++++++++++++++ gtk2_ardour/foldback_strip.h | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/foldback_strip.cc b/gtk2_ardour/foldback_strip.cc index d477f384f9..56c1cae126 100644 --- a/gtk2_ardour/foldback_strip.cc +++ b/gtk2_ardour/foldback_strip.cc @@ -1189,6 +1189,8 @@ FoldbackStrip::build_route_ops_menu () items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteUI::route_rename))); + items.push_back (MenuElem (_("Duplicate Foldback Bus"), sigc::mem_fun(*this, &FoldbackStrip::duplicate_current_fb))); + items.push_back (SeparatorElem()); items.push_back (CheckMenuElem (_("Active"))); Gtk::CheckMenuItem* i = dynamic_cast (&items.back()); @@ -1638,6 +1640,45 @@ FoldbackStrip::build_sends_menu () return menu; } +void +FoldbackStrip::duplicate_current_fb () +{ + RouteList new_rt_lst; + boost::shared_ptr new_fb; + boost::shared_ptr old_fb = _route; + string new_name_tp = "Foldback"; + // get number of io so long as it is 1 or 2 + uint32_t io = 1; + if (old_fb->n_outputs().n_audio() && (old_fb->n_outputs().n_audio() > 1)) { + io = 2; + } + + new_rt_lst = _session->new_audio_route (io, io, 0, 1, new_name_tp, PresentationInfo::FoldbackBus, (uint32_t) -1); + new_fb = *(new_rt_lst.begin()); + if (new_fb) { + double oldgain = old_fb->gain_control()->get_value(); + new_fb->gain_control()->set_value (oldgain * 0.25, PBD::Controllable::NoGroup); + + Route::FedBy fed_by = old_fb->fed_by(); + for (Route::FedBy::iterator i = fed_by.begin(); i != fed_by.end(); ++i) { + if (i->sends_only) { + boost::shared_ptr rt (i->r.lock()); + boost::shared_ptr old_snd = rt->internal_send_for (old_fb); + rt->add_foldback_send (new_fb); + if (old_snd) { + float old_gain = old_snd->gain_control()->get_value (); + boost::shared_ptr new_snd = rt->internal_send_for (new_fb); + new_snd->gain_control()->set_value (old_gain, PBD::Controllable::NoGroup); + } + } + } + set_route (new_fb); + route_rename (); + } else { + PBD::error << "Unable to create new FoldbackBus." << endmsg; + } +} + void FoldbackStrip::remove_current_fb () { diff --git a/gtk2_ardour/foldback_strip.h b/gtk2_ardour/foldback_strip.h index faabb0ca43..a4902cb8c7 100644 --- a/gtk2_ardour/foldback_strip.h +++ b/gtk2_ardour/foldback_strip.h @@ -161,7 +161,7 @@ public: bool delete_processors (); //note: returns false if nothing was deleted void toggle_processors (); void ab_plugins (); - + void duplicate_current_fb (); void set_selected (bool yn); static FoldbackStrip* entered_foldback_strip() { return _entered_foldback_strip; }