diff --git a/include/core/JamomaInterpolator.h b/include/core/JamomaInterpolator.h index b1937c9..e1f371f 100644 --- a/include/core/JamomaInterpolator.h +++ b/include/core/JamomaInterpolator.h @@ -29,8 +29,8 @@ namespace Jamoma { /** No interpolation always returns the first sample passed to it - @param x0 Sample value that will be returned - @param x1 Unused sample value + @param x0 Unused sample value + @param x1 Sample value that will be returned @param x2 Unused sample value @param x3 Unused sample value @param delta Unused fractional location @@ -41,27 +41,27 @@ namespace Jamoma { public: static const int delay = 0; - constexpr T operator()(T x0) noexcept { - return x0; + constexpr T operator()(T x1) noexcept { + return x1; } - constexpr T operator()(T x0, T x1, double delta) noexcept { - return x0; + constexpr T operator()(T x1, T x2, double delta) noexcept { + return x1; } constexpr T operator()(T x0, T x1, T x2, T x3, double delta) noexcept { - return x0; + return x1; } }; /** Nearest interpolation returns the closest sample by rounding the delta up or down. - @param x0 Returned sample value when rounding down - @param x1 Returned sample value when rounding up - @param x2 Unused sample value + @param x0 Unused sample value + @param x1 Returned sample value when rounding down + @param x2 Returned sample value when rounding up @param x3 Unused sample value - @param delta Fractional location between x0 and x1 @n - delta < 0.5 => x0 @n - delta >= 0.5 => x1 + @param delta Fractional location between x1 and x2 @n + delta < 0.5 => x1 @n + delta >= 0.5 => x2 @return The interpolated value */ template @@ -69,17 +69,17 @@ namespace Jamoma { public: static const int delay = 0; - constexpr T operator()(T x0) noexcept { - return x0; + constexpr T operator()(T x1) noexcept { + return x1; } - constexpr T operator()(T x0, T x1, double delta) noexcept { - T out = delta < 0.5 ? x0 : x1; + constexpr T operator()(T x1, T x2, double delta) noexcept { + T out = delta < 0.5 ? x1 : x2; return out; } constexpr T operator()(T x0, T x1, T x2, T x3, double delta) noexcept { - T out = delta < 0.5 ? x0 : x1; + T out = delta < 0.5 ? x1 : x2; return out; } }; diff --git a/test/Interpolator/Interpolator.cpp b/test/Interpolator/Interpolator.cpp index b3859f8..7aba0d5 100644 --- a/test/Interpolator/Interpolator.cpp +++ b/test/Interpolator/Interpolator.cpp @@ -36,25 +36,25 @@ class InterpolatorTest { auto x2 = 1.0; auto x3 = 4.0; - auto out = my_interp(x0); + auto out = my_interp(x1); - mTest->TEST_ASSERT("testNone with 1 sample produced correct output", out == x0); + mTest->TEST_ASSERT("testNone with 1 sample produced correct output", out == x1); - auto out2 = my_interp(x0,x1,0.25); + auto out2 = my_interp(x1,x2,0.25); - mTest->TEST_ASSERT("testNone with 2 samples, low delta produced correct output", out2 == x0); + mTest->TEST_ASSERT("testNone with 2 samples, low delta produced correct output", out2 == x1); - auto out2b = my_interp(x0,x1,0.75); + auto out2b = my_interp(x1,x2,0.75); - mTest->TEST_ASSERT("testNone with 2 samples, high delta produced correct output", out2b == x0); + mTest->TEST_ASSERT("testNone with 2 samples, high delta produced correct output", out2b == x1); auto out4 = my_interp(x0,x1,x2,x3,0.25); - mTest->TEST_ASSERT("testNone with 4 samples, low delta produced correct output", out4 == x0); + mTest->TEST_ASSERT("testNone with 4 samples, low delta produced correct output", out4 == x1); auto out4b = my_interp(x0,x1,x2,x3,0.75); - mTest->TEST_ASSERT("testNone with 4 samples, high delta produced correct output", out4b == x0); + mTest->TEST_ASSERT("testNone with 4 samples, high delta produced correct output", out4b == x1); }