13
0

stop crashes from out-of-range values

This commit is contained in:
Paul Davis 2016-09-23 15:24:45 -05:00
parent 7c82792a57
commit 879b09d920
2 changed files with 13 additions and 12 deletions

View File

@ -44,8 +44,9 @@
#include "ardour/vca_manager.h"
#include "canvas/colors.h"
#include "canvas/rectangle.h"
#include "canvas/line.h"
#include "canvas/rectangle.h"
#include "canvas/text.h"
#include "gtkmm2ext/gui_thread.h"
@ -400,15 +401,9 @@ MixLayout::strip_vpot (int n, int delta)
boost::shared_ptr<Controllable> ac = knobs[n]->controllable();
if (ac) {
if (ac->is_gain_like()) {
/* 128 steps from fader position 0 to 1.0 ..
*/
const double new_fader_position = min (1.0, max (0.0, ac->internal_to_interface (ac->get_value()) + ((1.0 / 128.0) * delta)));
ac->set_value (ac->interface_to_internal (new_fader_position), PBD::Controllable::UseGroup);
} else {
/* 128 steps from min to max */
ac->set_value (ac->get_value() + (((ac->upper() - ac->lower()) / 128.0) * delta) , PBD::Controllable::UseGroup);
}
ac->set_value (ac->interface_to_internal (
min (ac->upper(), max (ac->lower(), ac->internal_to_interface (ac->get_value()) + (delta/256.0)))),
PBD::Controllable::UseGroup);
}
}

View File

@ -1094,7 +1094,11 @@ Push2::other_vpot (int n, int delta)
click_gain = session->click_gain();
if (click_gain) {
boost::shared_ptr<AutomationControl> ac = click_gain->gain_control();
ac->set_value (ac->interface_to_internal (ac->internal_to_interface (ac->get_value()) + (delta/128.0)), PBD::Controllable::UseGroup);
if (ac) {
ac->set_value (ac->interface_to_internal (
min (ac->upper(), max (ac->lower(), ac->internal_to_interface (ac->get_value()) + (delta/256.0)))),
PBD::Controllable::UseGroup);
}
}
break;
case 2:
@ -1102,7 +1106,9 @@ Push2::other_vpot (int n, int delta)
if (master) {
boost::shared_ptr<AutomationControl> ac = master->gain_control();
if (ac) {
ac->set_value (ac->interface_to_internal (ac->internal_to_interface (ac->get_value()) + (delta/128.0)), PBD::Controllable::UseGroup);
ac->set_value (ac->interface_to_internal (
min (ac->upper(), max (ac->lower(), ac->internal_to_interface (ac->get_value()) + (delta/256.0)))),
PBD::Controllable::UseGroup);
}
}
break;