diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-23 15:24:45 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-27 14:59:32 -0500 |
commit | 879b09d9202210f45e984f6dd1c529f3209b1b96 (patch) | |
tree | 8caa9a12adecb84b2a7cbb8f5f9a59255dd49cf6 /libs/surfaces/push2 | |
parent | 7c82792a573252f7de022345088cb25294251050 (diff) |
stop crashes from out-of-range values
Diffstat (limited to 'libs/surfaces/push2')
-rw-r--r-- | libs/surfaces/push2/mix.cc | 15 | ||||
-rw-r--r-- | libs/surfaces/push2/push2.cc | 10 |
2 files changed, 13 insertions, 12 deletions
diff --git a/libs/surfaces/push2/mix.cc b/libs/surfaces/push2/mix.cc index 58e29fc877..c61ee45008 100644 --- a/libs/surfaces/push2/mix.cc +++ b/libs/surfaces/push2/mix.cc @@ -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); } } diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index fb33a916cb..7e9316c17e 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -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; |