summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-01-19 10:24:25 +0100
committerRobin Gareus <robin@gareus.org>2019-01-19 12:08:54 +0100
commitbf728520ca7e1de9b0ba565478d655afec91ad1f (patch)
tree3d8aa2fac475fafcaead7d49ae8a2667803e684f /libs/pbd
parent616ee4e43ba09433836896ecc5fa5163b3188c12 (diff)
Optimize exponential interpolation.
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/pbd/control_math.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/libs/pbd/pbd/control_math.h b/libs/pbd/pbd/control_math.h
index 9a59a3c9e5..c4f0566226 100644
--- a/libs/pbd/pbd/control_math.h
+++ b/libs/pbd/pbd/control_math.h
@@ -86,12 +86,18 @@ interpolate_linear (double from, double to, double fraction)
}
static inline double
-interpolate_logarithmic (double from, double to, double fraction, double lower, double upper)
+interpolate_logarithmic (double from, double to, double fraction, double /*lower*/, double /*upper*/)
{
- // this is expensive -- optimize
+#if 0
+ /* this is expensive, original math incl. range-check assertions */
double l0 = logscale_to_position (from, lower, upper);
double l1 = logscale_to_position (to, lower, upper);
return position_to_logscale (l0 + fraction * (l1 - l0), lower, upper);
+#else
+ assert (from > 0 && from * to > 0);
+ assert (fraction >= 0 && fraction <= 1);
+ return from * pow (to / from, fraction);
+#endif
}
static inline double