-};
-
-double slider_fraction_to_db(double db)
-{
- if (db >= fader_control_points[0].second) {
- return fader_control_points[0].first;
- }
- if (db <= fader_control_points.back().second) {
- return fader_control_points.back().first;
- }
- for (unsigned i = 1; i < fader_control_points.size(); ++i) {
- const double x0 = fader_control_points[i].second;
- const double x1 = fader_control_points[i - 1].second;
- const double y0 = fader_control_points[i].first;
- const double y1 = fader_control_points[i - 1].first;
- if (db >= x0 && db <= x1) {
- const double t = (db - x0) / (x1 - x0);
- return y0 + t * (y1 - y0);
- }
- }
- assert(false);
-}
-
-double db_to_slider_fraction(double x)
-{
- if (x >= fader_control_points[0].first) {
- return fader_control_points[0].second;
- }
- if (x <= fader_control_points.back().first) {
- return fader_control_points.back().second;
- }
- for (unsigned i = 1; i < fader_control_points.size(); ++i) {
- const double x0 = fader_control_points[i].first;
- const double x1 = fader_control_points[i - 1].first;
- const double y0 = fader_control_points[i].second;
- const double y1 = fader_control_points[i - 1].second;
- if (x >= x0 && x <= x1) {
- const double t = (x - x0) / (x1 - x0);
- return y0 + t * (y1 - y0);
- }
- }
- assert(false);
-}