diff --git a/include/dsp/minblep.hpp b/include/dsp/minblep.hpp index a35772e7..bd64cacc 100644 --- a/include/dsp/minblep.hpp +++ b/include/dsp/minblep.hpp @@ -15,9 +15,9 @@ https://www.cs.cmu.edu/~eli/papers/icmc01-hardsync.pdf void minBlepImpulse(int z, int o, float *output); -template +template struct MinBlepGenerator { - float buf[2 * Z] = {}; + T buf[2 * Z] = {}; int pos = 0; float impulse[2 * Z * O + 1]; @@ -27,7 +27,7 @@ struct MinBlepGenerator { } /** Places a discontinuity with magnitude `x` at -1 < p <= 0 relative to the current frame */ - void insertDiscontinuity(float p, float x) { + void insertDiscontinuity(float p, T x) { if (!(-1 < p && p <= 0)) return; for (int j = 0; j < 2 * Z; j++) { @@ -37,9 +37,9 @@ struct MinBlepGenerator { } } - float process() { - float v = buf[pos]; - buf[pos] = 0.f; + T process() { + T v = buf[pos]; + buf[pos] = T(0); pos = (pos + 1) % (2 * Z); return v; } diff --git a/include/simd/functions.hpp b/include/simd/functions.hpp index 9d2ee86f..3cbc2800 100644 --- a/include/simd/functions.hpp +++ b/include/simd/functions.hpp @@ -172,6 +172,12 @@ inline float_4 rescale(float_4 x, float_4 xMin, float_4 xMax, float_4 yMin, floa return yMin + (x - xMin) / (xMax - xMin) * (yMax - yMin); } +using math::crossfade; + +inline float_4 crossfade(float_4 a, float_4 b, float_4 p) { + return a + (b - a) * p; +} + using math::sgn; inline float_4 sgn(float_4 x) {