1 #ifndef _PIECEWISE_INTERPOLATOR_H
2 #define _PIECEWISE_INTERPOLATOR_H
4 // A class to do piecewise linear interpolation of one scale to another
5 // (and back). Typically used to implement nonlinear dB mappings for sliders
6 // or meters, thus the nomenclature.
10 class PiecewiseInterpolator {
12 // Both dB and fraction values must go from high to low.
17 PiecewiseInterpolator(const std::vector<ControlPoint> &control_points)
18 : control_points(control_points) {}
20 double fraction_to_db(double db) const;
21 double db_to_fraction(double x) const;
24 const std::vector<ControlPoint> control_points;
27 #endif // !defined(_PIECEWISE_INTERPOLATOR_H)