-
- /* 30 happens to be the total number of steps for a fader with default
- max gain of 2.0 (6 dB), so we use 30 here too for consistency. */
- step = smallstep = (delta / 300.0f);
- largestep = (delta / 30.0f);
-
- if (logarithmic) {
- /* Steps are linear, but we map them with pow like values (in
- internal_to_interface). Thus, they are applied exponentially,
- which means too few steps. So, divide to get roughly the
- desired number of steps (30). This is not mathematically
- precise but seems to be about right for the controls I tried.
- If you're reading this, you've probably found a case where that
- isn't true, and somebody needs to sit down with a piece of paper
- and actually do the math. */
- smallstep = smallstep / logf(30.0f);
- step = step / logf(30.0f);
- largestep = largestep / logf(30.0f);
- } else if (integer_step) {
- smallstep = 1.0;
- step = std::max(1.f, rintf (step));
- largestep = std::max(1.f, rintf (largestep));
+ if (integer_step) {
+ smallstep = step = 1.0;
+ largestep = std::max(1.f, rintf (delta / (rangesteps - 1.f)));
+ } else {
+ step = smallstep = delta / (rangesteps - 1.f);
+ largestep = std::min ((delta / 4.0f), 10.f * smallstep);
+ }
+ } else {
+ const float delta = upper - lower;
+ /* 30 steps between min/max (300 for fine-grained) */
+ if (integer_step) {
+ smallstep = step = 1.0;
+ largestep = std::max(1.f, rintf (delta / 30.f));
+ } else {
+ step = smallstep = (delta / 300.0f);
+ largestep = (delta / 30.0f);