diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-06-20 13:58:33 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-06-20 13:58:33 +0000 |
commit | b27233293306324c6a2ee598dcb5d0248c7e1e16 (patch) | |
tree | bb46e36eea16d1086e9139c8a846759eccc03eb8 /gtk2_ardour/volume_controller.cc | |
parent | 12c844dd8de41e8ba55db2598d30000fcce45cc1 (diff) |
change VolumeController::adjust() to do discrete dB increments+decrements
git-svn-id: svn://localhost/ardour2/branches/3.0@9750 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/volume_controller.cc')
-rw-r--r-- | gtk2_ardour/volume_controller.cc | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/gtk2_ardour/volume_controller.cc b/gtk2_ardour/volume_controller.cc index 365379933d..7d6a3362de 100644 --- a/gtk2_ardour/volume_controller.cc +++ b/gtk2_ardour/volume_controller.cc @@ -133,11 +133,11 @@ VolumeController::to_display_value (double control_value) { double v; -// if (_linear) { + if (_linear) { v = (control_value - _controllable->lower ()) / (_controllable->upper() - _controllable->lower()); -// } else { -// v = gain_to_slider_position_with_max (control_value, ARDOUR::Config->get_max_gain()); -// } + } else { + v = gain_to_slider_position_with_max (control_value, ARDOUR::Config->get_max_gain()); + } return v; } @@ -145,6 +145,25 @@ VolumeController::to_display_value (double control_value) double VolumeController::adjust (double control_delta) { - return std::max (_controllable->lower(), std::min (_controllable->upper(), _controllable->get_value() + control_delta)); -} + double v = _controllable->get_value (); + double abs_delta = fabs (control_delta); + + /* convert to linear/fractional slider position domain */ + v = gain_to_slider_position_with_max (v, ARDOUR::Config->get_max_gain()); + /* adjust in this domain */ + v += control_delta; + /* convert back to gain coefficient domain */ + v = slider_position_to_gain_with_max (v, ARDOUR::Config->get_max_gain()); + /* now round to some precision in the dB domain */ + v = accurate_coefficient_to_dB (v); + + if (abs_delta <= 0.01) { + v -= fmod (v, 0.05); + } else { + v -= fmod (v, 0.1); + } + + /* and return it */ + return dB_to_coefficient (v); +} |