From 46315cde5707feabee6487804460e5ebc7a466c6 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 6 May 2024 16:18:58 -0600 Subject: [PATCH] T: save/restore master send levels across virtual soundcheck toggle --- libs/ardour/ardour/session.h | 1 + libs/ardour/session.cc | 35 ++++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index c5c0fee6ea..058b02b488 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -2457,6 +2457,7 @@ private: bool _virtual_soundcheck; std::atomic _no_livetrax_auto_connect; + std::map livetrax_vs_msend_values; }; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 6745c8aa4a..232a78a092 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -8380,9 +8380,7 @@ Session::set_virtual_soundcheck (bool yn) std::shared_ptr rl = routes.reader (); std::shared_ptr master_sends (new AutomationControlList); std::shared_ptr main_outs (new AutomationControlList); - - gain_t main_val = (yn ? 1. : 0.); - gain_t send_val = (yn ? 0. : 1.); + std::vector values; for (auto & route : *rl) { @@ -8391,14 +8389,37 @@ Session::set_virtual_soundcheck (bool yn) } master_sends->push_back (route->master_send()->gain_control()); - // virtual_soundcheck_msend_values.insert (std::make_pair (route, route->master_send()->gain_control()->get_value())); main_outs->push_back (route->main_outs()->gain_control()); - // virtual_soundcheck_direct_values.insert (std::make_pair (route, route->main_outs()->gain_control()->get_value())); + + if (yn) { + /* Save current values for master send gain before we turn it off */ + double g = route->master_send()->gain_control()->get_value(); + auto result = livetrax_vs_msend_values.insert (std::make_pair (route->id(), g)); + if (!result.second) { + result.first->second = g; + } + + } else { + /* Lookup master send gain values from before we turned them off */ + std::map::iterator v = livetrax_vs_msend_values.find (route->id()); + if (v == livetrax_vs_msend_values.end()) { + /* not found - use a default */ + values.push_back (1.0); + } else { + values.push_back (v->second); + } + } } if (!master_sends->empty()) { - set_controls (master_sends, send_val, PBD::Controllable::NoGroup); - set_controls (main_outs, main_val, PBD::Controllable::NoGroup); + if (yn) { + set_controls (master_sends, 0., PBD::Controllable::NoGroup); + set_controls (main_outs, 1., PBD::Controllable::NoGroup); + } else { + assert (master_sends->size() == values.size()); + set_controls_with_values (master_sends, values, PBD::Controllable::NoGroup); + set_controls (main_outs, 0., PBD::Controllable::NoGroup); + } } _virtual_soundcheck = yn;