From 64c9198d602a86cf584cf84157470edd1ee2caf0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 18 Jan 2016 10:52:15 -0500 Subject: [PATCH] add group disposition argument to Route::set_gain() and use it in various UIs Executive decisions were necessary in a couple of places about the correct group disposition behaviour, notably faderport and OSC surfaces --- gtk2_ardour/gain_meter.cc | 2 +- gtk2_ardour/mixer_actor.cc | 2 +- gtk2_ardour/route_ui.cc | 8 ++++---- libs/ardour/ardour/route.h | 4 ++-- libs/ardour/audio_track.cc | 2 +- libs/ardour/route.cc | 14 +++++++------- libs/ardour/session.cc | 2 +- libs/surfaces/control_protocol/control_protocol.cc | 2 +- libs/surfaces/faderport/faderport.cc | 6 +++++- libs/surfaces/osc/osc.cc | 2 +- 10 files changed, 24 insertions(+), 20 deletions(-) diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index 7fa9bf88de..5a2047cf73 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -532,7 +532,7 @@ GainMeterBase::gain_adjusted () if (!ignore_toggle) { if (_route && _route->amp() == _amp) { - _route->set_gain (value, this); + _route->set_gain (value, Controllable::UseGroup); } else { _amp->gain_control()->set_value (value, Controllable::NoGroup); } diff --git a/gtk2_ardour/mixer_actor.cc b/gtk2_ardour/mixer_actor.cc index ffd68ff6c4..87a4d014e6 100644 --- a/gtk2_ardour/mixer_actor.cc +++ b/gtk2_ardour/mixer_actor.cc @@ -176,7 +176,7 @@ printf("setting gain to unity (?)"); BOOST_FOREACH(RouteUI* r, _route_targets) { boost::shared_ptr rp = r->route(); if (rp) { - rp->set_gain (1.0, this); + rp->set_gain (1.0, Controllable::NoGroup); } } } diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index a3fa56945d..059f20a885 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -1949,25 +1949,25 @@ RouteUI::parameter_changed (string const & p) void RouteUI::step_gain_up () { - _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) + 0.1), this); + _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) + 0.1), Controllable::UseGroup); } void RouteUI::page_gain_up () { - _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) + 0.5), this); + _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) + 0.5), Controllable::UseGroup); } void RouteUI::step_gain_down () { - _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.1), this); + _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.1), Controllable::UseGroup); } void RouteUI::page_gain_down () { - _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.5), this); + _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.5), Controllable::UseGroup); } void diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index a57610ab98..e3eec71078 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -142,8 +142,8 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou void shift (framepos_t, framecnt_t); - void set_gain (gain_t val, void *src); - void inc_gain (gain_t delta, void *src); + void set_gain (gain_t val, PBD::Controllable::GroupControlDisposition); + void inc_gain (gain_t delta); void set_trim (gain_t val, void *src); diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index f5d5207cc6..47746ffe31 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -629,7 +629,7 @@ AudioTrack::freeze_me (InterThreadInfo& itt) /* reset stuff that has already been accounted for in the freeze process */ - set_gain (GAIN_COEFF_UNITY, this); + set_gain (GAIN_COEFF_UNITY, Controllable::NoGroup); _amp->gain_control()->set_automation_state (Off); /* XXX need to use _main_outs _panner->set_automation_state (Off); */ diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index a23af603de..c07612f125 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -387,7 +387,7 @@ Route::ensure_track_or_route_name(string name, Session &session) } void -Route::inc_gain (gain_t factor, void *src) +Route::inc_gain (gain_t factor) { /* To be used ONLY when doing group-relative gain adjustment, from * ::set_gain() @@ -404,9 +404,9 @@ Route::inc_gain (gain_t factor, void *src) } void -Route::set_gain (gain_t val, void *src) +Route::set_gain (gain_t val, Controllable::GroupControlDisposition group_override) { - if (src != 0 && _route_group && src != _route_group && _route_group->is_active() && _route_group->is_gain()) { + if (_route_group && (group_override != Controllable::NoGroup) && _route_group->is_active() && _route_group->is_gain()) { if (_route_group->is_relative()) { @@ -441,11 +441,11 @@ Route::set_gain (gain_t val, void *src) } } - _route_group->foreach_route (boost::bind (&Route::inc_gain, _1, factor, _route_group)); + _route_group->foreach_route (boost::bind (&Route::inc_gain, _1, factor)); } else { - _route_group->foreach_route (boost::bind (&Route::set_gain, _1, val, _route_group)); + _route_group->foreach_route (boost::bind (&Route::set_gain, _1, val, Controllable::NoGroup)); } return; @@ -3894,14 +3894,14 @@ Route::set_latency_compensation (framecnt_t longest_session_latency) } void -Route::set_control (AutomationType type, double val, PBD::Controllable::GroupControlDisposition /*group_override*/) +Route::set_control (AutomationType type, double val, PBD::Controllable::GroupControlDisposition group_override) { boost::shared_ptr rl; switch (type) { case GainAutomation: /* route must mediate group control */ - set_gain (val, this); /* any "src" argument will do other than our route group */ + set_gain (val, group_override); return; break; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index c20a7709ce..3da7f6c071 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2880,7 +2880,7 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod // 0 for Stereo Out mode // 0 Multi Out mode if (Config->get_output_auto_connect() & AutoConnectMaster) { - track->set_gain (dB_to_coefficient (0), 0); + track->set_gain (dB_to_coefficient (0), Controllable::NoGroup); } } diff --git a/libs/surfaces/control_protocol/control_protocol.cc b/libs/surfaces/control_protocol/control_protocol.cc index 52aaa51e6e..1ce51bcd75 100644 --- a/libs/surfaces/control_protocol/control_protocol.cc +++ b/libs/surfaces/control_protocol/control_protocol.cc @@ -248,7 +248,7 @@ ControlProtocol::route_set_gain (uint32_t table_index, float gain) boost::shared_ptr r = route_table[table_index]; if (r != 0) { - r->set_gain (gain, this); + r->set_gain (gain, Controllable::UseGroup); } } diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index 9481445af2..50250a5f13 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -499,7 +499,11 @@ FaderPort::fader_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb) if (gain) { int ival = (fader_msb << 7) | fader_lsb; float val = gain->interface_to_internal (ival/16384.0); - _current_route->set_gain (val, this); + /* even though the faderport only controls a + single route at a time, allow the fader to + modify the group, if appropriate. + */ + _current_route->set_gain (val, Controllable::UseGroup); } } } diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 31fd146a5f..328acc7222 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -1013,7 +1013,7 @@ OSC::route_set_gain_abs (int rid, float level) boost::shared_ptr r = session->route_by_remote_id (rid); if (r) { - r->set_gain (level, this); + r->set_gain (level, PBD::Controllable::NoGroup); } return 0;