- 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;
- /* clamp in this domain */
- v = std::max (0.0, std::min (1.0, v));
- /* convert back to gain coefficient domain */
- v = slider_position_to_gain_with_max (v, ARDOUR::Config->get_max_gain());
- /* clamp in this domain */
- v = std::max (_controllable->lower(), std::min (_controllable->upper(), v));
-
- /* 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);
+ double v;
+
+ if (!_linear) {
+
+ /* we map back into the linear/fractional slider position,
+ * because this kind of control goes all the way down
+ * to -inf dB, and we want this occur in a reasonable way in
+ * terms of user interaction. if we leave the adjustment in the
+ * gain coefficient domain (or dB domain), the lower end of the
+ * control range (getting close to -inf dB) takes forever.
+ */
+
+ /* convert to linear/fractional slider position domain */
+ v = gain_to_slider_position_with_max (_controllable->get_value (), _controllable->upper());
+ /* increment in this domain */
+ v += control_delta;
+ /* clamp to appropriate range for linear/fractional slider domain */
+ v = std::max (0.0, std::min (1.0, v));
+ /* convert back to gain coefficient domain */
+ v = slider_position_to_gain_with_max (v, _controllable->upper());
+ /* clamp in controller domain */
+ v = std::max (_controllable->lower(), std::min (_controllable->upper(), v));
+ /* convert to dB domain */
+ v = accurate_coefficient_to_dB (v);
+ /* round up/down to nearest 0.1dB */
+ if (control_delta > 0.0) {
+ v = ceil (v * 10.0) / 10.0;
+ } else {
+ v = floor (v * 10.0) / 10.0;
+ }
+ /* and return it */
+ return dB_to_coefficient (v);