ft2-clone

Fasttracker 2 clone
Log | Files | Refs | README | LICENSE

commit cbfbcc413d629aa99bdf7f1f1b6b7b67a569e095
parent 65ae4b974e929be2bf6340739a17e9c9dcf70d67
Author: Olav Sørensen <olav.sorensen@live.no>
Date:   Fri, 23 Feb 2024 17:28:15 +0100

Cubic spline code cleanup

Diffstat:
Msrc/mixer/ft2_cubic_spline.c | 10+++++-----
Msrc/mixer/ft2_cubic_spline.h | 2+-
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mixer/ft2_cubic_spline.c b/src/mixer/ft2_cubic_spline.c @@ -18,13 +18,13 @@ bool calcCubicSplineTable(void) float *fPtr = fCubicSplineLUT; for (int32_t i = 0; i < CUBIC_SPLINE_PHASES; i++) { - const double x = i * (1.0 / CUBIC_SPLINE_PHASES); // x = i / CUBIC_SPLINE_PHASES - const double x2 = x * x; // x^2 - const double x3 = x2 * x; // x^3 + const double x1 = i * (1.0 / (double)CUBIC_SPLINE_PHASES); // i / CUBIC_SPLINE_PHASES + const double x2 = x1 * x1; // x^2 + const double x3 = x2 * x1; // x^3 - *fPtr++ = (float)(-0.5 * x3 + 1.0 * x2 - 0.5 * x); + *fPtr++ = (float)(-0.5 * x3 + 1.0 * x2 - 0.5 * x1); *fPtr++ = (float)( 1.5 * x3 - 2.5 * x2 + 1.0); - *fPtr++ = (float)(-1.5 * x3 + 2.0 * x2 + 0.5 * x); + *fPtr++ = (float)(-1.5 * x3 + 2.0 * x2 + 0.5 * x1); *fPtr++ = (float)( 0.5 * x3 - 0.5 * x2); } diff --git a/src/mixer/ft2_cubic_spline.h b/src/mixer/ft2_cubic_spline.h @@ -5,7 +5,7 @@ #include "ft2_mix.h" // MIXER_FRAC_BITS #define CUBIC_SPLINE_TAPS 4 -#define CUBIC_WIDTH_BITS 2 +#define CUBIC_WIDTH_BITS 2 // log2(CUBIC_SPLINE_TAPS) // 8192 is a good compromise #define CUBIC_SPLINE_PHASES 8192