generally avoid use of Config->get_max_gain() and use Controllable::upper() instead

This allows already working code to keep working if used with GainControls whose gain range differs
from the default (Config->get_max_gain() sets the upper value)
This commit is contained in:
Paul Davis 2025-05-05 13:48:53 -06:00
parent 9deee4df7c
commit 44231557e2
5 changed files with 19 additions and 19 deletions

View file

@ -78,7 +78,7 @@ ParameterDescriptor::ParameterDescriptor(const Evoral::Parameter& parameter)
logarithmic = true;
break;
case MainOutVolume:
upper = 100; // +40dB
upper = 15.85; // +24B
lower = .01; // -40dB
normal = 1.0f;
logarithmic = true;

View file

@ -2969,7 +2969,7 @@ VST3PI::getContextInfoValue (double& value, FIDString id)
if (0 == strcmp (id, ContextInfo::kMaxVolume)) {
value = s->gain_control ()->upper ();
} else if (0 == strcmp (id, ContextInfo::kMaxSendLevel)) {
value = 2.0; // Config->get_max_gain();
value = Config->get_max_gain();
#ifdef MIXBUS
if (s->send_enable_controllable (0)) {
assert (s->send_level_controllable (0));

View file

@ -1549,7 +1549,7 @@ LaunchKey4::fader_move (int which, int val)
}
if (ac) {
gain_t gain = ARDOUR::slider_position_to_gain_with_max (val/127.0, ARDOUR::Config->get_max_gain());
gain_t gain = ARDOUR::slider_position_to_gain_with_max (val/127.0, ac->upper());
session->set_control (ac, gain, PBD::Controllable::NoGroup);
char buf[16];
@ -1574,7 +1574,7 @@ LaunchKey4::automation_control_change (int n, std::weak_ptr<AutomationControl> w
case VolumeFaders:
case SendAFaders:
case SendBFaders:
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ARDOUR::Config->get_max_gain()) * 127.0);
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ac->upper()) * 127.0);
break;
case PanFaders:
msg[2] = (MIDI::byte) (ac->get_value() * 127.0);
@ -1779,9 +1779,9 @@ LaunchKey4::encoder_level (int which, int step)
if (shift_pressed) {
gain = gc->get_value();
} else {
double pos = ARDOUR::gain_to_slider_position_with_max (gc->get_value(), ARDOUR::Config->get_max_gain());
double pos = ARDOUR::gain_to_slider_position_with_max (gc->get_value(), gc->upper());
pos += (step/127.0);
gain = ARDOUR::slider_position_to_gain_with_max (pos, ARDOUR::Config->get_max_gain());
gain = ARDOUR::slider_position_to_gain_with_max (pos, gc->upper());
session->set_control (gc, gain, Controllable::NoGroup);
}
@ -1827,9 +1827,9 @@ LaunchKey4::encoder_senda (int which, int step)
/* Just display current value */
gain = gc->get_value();
} else {
double pos = ARDOUR::gain_to_slider_position_with_max (gc->get_value(), ARDOUR::Config->get_max_gain());
double pos = ARDOUR::gain_to_slider_position_with_max (gc->get_value(), gc->upper());
pos += (step/127.0);
gain = ARDOUR::slider_position_to_gain_with_max (pos, ARDOUR::Config->get_max_gain());
gain = ARDOUR::slider_position_to_gain_with_max (pos, gc->upper());
session->set_control (gc, gain, Controllable::NoGroup);
}

View file

@ -1969,7 +1969,7 @@ LaunchPadPro::fader_move (int cc, int val)
case VolumeFaders:
ac = r->gain_control();
if (ac) {
session->set_control (ac, ARDOUR::slider_position_to_gain_with_max (val/127.0, ARDOUR::Config->get_max_gain()), PBD::Controllable::NoGroup);
session->set_control (ac, ARDOUR::slider_position_to_gain_with_max (val/127.0, ac->upper()), PBD::Controllable::NoGroup);
}
break;
case PanFaders:
@ -1981,7 +1981,7 @@ LaunchPadPro::fader_move (int cc, int val)
case SendFaders:
ac = r->send_level_controllable (scroll_x_offset + (cc - first_fader));
if (ac) {
session->set_control (ac, ARDOUR::slider_position_to_gain_with_max (val/127.0, ARDOUR::Config->get_max_gain()), PBD::Controllable::NoGroup);
session->set_control (ac, ARDOUR::slider_position_to_gain_with_max (val/127.0, ac->upper()), PBD::Controllable::NoGroup);
}
break;
default:
@ -2032,7 +2032,7 @@ LaunchPadPro::map_faders ()
case VolumeFaders:
ac = r->gain_control();
if (ac) {
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ARDOUR::Config->get_max_gain()) * 127.0);
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ac->upper()) * 127.0);
} else {
msg[2] = 0;
}
@ -2048,7 +2048,7 @@ LaunchPadPro::map_faders ()
case SendFaders:
ac = r->send_level_controllable (n);
if (ac) {
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ARDOUR::Config->get_max_gain()) * 127.0);
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ac->upper()) * 127.0);
} else {
msg[2] = 0;
}
@ -2081,7 +2081,7 @@ LaunchPadPro::automation_control_change (int n, std::weak_ptr<AutomationControl>
switch (current_fader_bank) {
case VolumeFaders:
case SendFaders:
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ARDOUR::Config->get_max_gain()) * 127.0);
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ac->upper()) * 127.0);
break;
case PanFaders:
msg[2] = (MIDI::byte) (ac->get_value() * 127.0);

View file

@ -1666,7 +1666,7 @@ LaunchPadX::fader_move (int cc, int val)
case VolumeFaders:
ac = r->gain_control();
if (ac) {
session->set_control (ac, ARDOUR::slider_position_to_gain_with_max (val/127.0, ARDOUR::Config->get_max_gain()), PBD::Controllable::NoGroup);
session->set_control (ac, ARDOUR::slider_position_to_gain_with_max (val/127.0, ac->upper()), PBD::Controllable::NoGroup);
}
break;
case PanFaders:
@ -1678,7 +1678,7 @@ LaunchPadX::fader_move (int cc, int val)
case SendAFaders:
ac = r->send_level_controllable (scroll_x_offset + (cc - first_fader));
if (ac) {
session->set_control (ac, ARDOUR::slider_position_to_gain_with_max (val/127.0, ARDOUR::Config->get_max_gain()), PBD::Controllable::NoGroup);
session->set_control (ac, ARDOUR::slider_position_to_gain_with_max (val/127.0, ac->upper()), PBD::Controllable::NoGroup);
}
break;
case SendBFaders:
@ -1731,7 +1731,7 @@ LaunchPadX::map_faders ()
case VolumeFaders:
ac = r->gain_control();
if (ac) {
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ARDOUR::Config->get_max_gain()) * 127.0);
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ac->upper()) * 127.0);
} else {
msg[2] = 0;
}
@ -1747,7 +1747,7 @@ LaunchPadX::map_faders ()
case SendAFaders:
ac = r->send_level_controllable (0);
if (ac) {
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ARDOUR::Config->get_max_gain()) * 127.0);
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ac->upper()) * 127.0);
} else {
msg[2] = 0;
}
@ -1755,7 +1755,7 @@ LaunchPadX::map_faders ()
case SendBFaders:
ac = r->send_level_controllable (1);
if (ac) {
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ARDOUR::Config->get_max_gain()) * 127.0);
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ac->upper()) * 127.0);
} else {
msg[2] = 0;
}
@ -1789,7 +1789,7 @@ LaunchPadX::automation_control_change (int n, std::weak_ptr<AutomationControl> w
case VolumeFaders:
case SendAFaders:
case SendBFaders:
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ARDOUR::Config->get_max_gain()) * 127.0);
msg[2] = (MIDI::byte) (ARDOUR::gain_to_slider_position_with_max (ac->get_value(), ac->upper()) * 127.0);
break;
case PanFaders:
msg[2] = (MIDI::byte) (ac->get_value() * 127.0);