13
0

revert GainMeter back to simpler code now that VCA model appears correct

This commit is contained in:
Paul Davis 2016-03-03 22:48:03 -05:00
parent 562ec7df8f
commit a38aabfce3

View File

@ -526,49 +526,11 @@ GainMeterBase::fader_moved ()
if (!ignore_toggle) {
gain_t value;
const gain_t master_gain = _control->get_master_gain ();
/* convert from adjustment range (0..1) to gain coefficient */
if (_data_type == DataType::AUDIO) {
if (_control->slaved ()) {
/* fader has been moved. The initial position of the fader
reflects any master gain (see ::gain_changed() below). So
when we reset the actual gain value, we have to remove the
influence of the master gain (if any).
but ... the fader is non-linear. a given number of dB will have a
relatively small effect on fader position far from the 0dB
position, and a larger effect near to it.
so... we take the current gain value, and compute where the
fader was BEFORE it was moved. Then we compute how the
position delta that the master gain caused.
once we have that value, we subtract it from the current
fader position, which gives us the current fader position as
if there was no master.
*/
const gain_t current_value = _control->get_value (); /* current value */
const float position_delta_caused_by_master = gain_to_slider_position_with_max (current_value * master_gain, Config->get_max_gain()) -
gain_to_slider_position_with_max (current_value, Config->get_max_gain());
/* this is "where would the fader be now if the master
wan't changing things?"
*/
const float adjusted_position = min (gain_adjustment.get_upper(), max (gain_adjustment.get_lower(), gain_adjustment.get_value() - position_delta_caused_by_master));
value = slider_position_to_gain_with_max (adjusted_position, Config->get_max_gain());
} else {
value = slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain());
}
value = slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain());
} else {
value = gain_adjustment.get_value();
}
@ -593,7 +555,7 @@ GainMeterBase::effective_gain_display ()
/* the position of the fader should reflect any master gain,
* not just the control's own inherent value
*/
fader_position = gain_to_slider_position_with_max (_control->get_value() * _control->get_master_gain(), Config->get_max_gain());
fader_position = gain_to_slider_position_with_max (_control->get_value(), Config->get_max_gain());
break;
case DataType::MIDI:
fader_position = _control->get_value ();