13
0

T: save/restore master send levels across virtual soundcheck toggle

This commit is contained in:
Paul Davis 2024-05-06 16:18:58 -06:00
parent 801ae34c15
commit 46315cde57
2 changed files with 29 additions and 7 deletions

View File

@ -2457,6 +2457,7 @@ private:
bool _virtual_soundcheck;
std::atomic<uint32_t> _no_livetrax_auto_connect;
std::map<PBD::ID,double> livetrax_vs_msend_values;
};

View File

@ -8380,9 +8380,7 @@ Session::set_virtual_soundcheck (bool yn)
std::shared_ptr<RouteList const> rl = routes.reader ();
std::shared_ptr<AutomationControlList> master_sends (new AutomationControlList);
std::shared_ptr<AutomationControlList> main_outs (new AutomationControlList);
gain_t main_val = (yn ? 1. : 0.);
gain_t send_val = (yn ? 0. : 1.);
std::vector<double> 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<PBD::ID,double>::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;