diff --git a/src/amy_fixedpoint.h b/src/amy_fixedpoint.h index 0a423f86..f48fb708 100644 --- a/src/amy_fixedpoint.h +++ b/src/amy_fixedpoint.h @@ -95,6 +95,7 @@ #define S_FRAC_OF_S(s, b) ((s) * (1 << (b)) - floorf((s) * (1 << (b)))) #define MUL0_SS(a, b) ((a) * (b)) +#define MUL1_SS(a, b) ((a) * (b)) #define MUL4_SS(a, b) ((a) * (b)) #define MUL5A_SS(a, b) ((a) * (b)) #define MUL6A_SS(a, b) ((a) * (b)) @@ -319,6 +320,9 @@ static inline SAMPLE SMULR7(SAMPLE a, SAMPLE b) { // Multiply two SAMPLE values when the result will always be [-1.0, 1.0). #define MUL0_SS(a, b) FXMUL_TEMPLATE(a, b, 8, 7, S_FRAC_BITS) // 8+7 = 15, so additional 8 bits shift right on output to make 23 req'd total. +// Multiply two SAMPLE values when the result will always be [-2.0, 2.0). +#define MUL1_SS(a, b) FXMUL_TEMPLATE(a, b, 9, 7, S_FRAC_BITS) // 9+7 = 16, so result is >>1, leaving 1 bit integer part. + // Multiply two SAMPLE values when the result will always be [-16.0, 16.0). #define MUL4_SS(a, b) FXMUL_TEMPLATE(a, b, 10, 9, S_FRAC_BITS) // 10+9 = 19, so result is >>4, leaving 4 bits integer part. diff --git a/src/oscillators.c b/src/oscillators.c index 563f362b..638b257c 100644 --- a/src/oscillators.c +++ b/src/oscillators.c @@ -91,7 +91,7 @@ const LUT *choose_from_lutset(float period, const LUT *lutset) { INTERP_PART #define INTERP_LINEAR \ - sample = b + MUL0_SS(c - b, frac); + sample = b + MUL1_SS(c - b, frac); /* c - b reaches 2.0 across a full-scale edge */ // Miller's optimization - // https://github.com/pure-data/pure-data/blob/db777311d808bb3ba728b94ab067f8d333b7d0c2/src/d_array.c#L831C1-L833C76 diff --git a/tests/ref/TestNotchFilter.wav b/tests/ref/TestNotchFilter.wav index 6418d91a..216101b9 100644 Binary files a/tests/ref/TestNotchFilter.wav and b/tests/ref/TestNotchFilter.wav differ diff --git a/tests/ref/TestOverload.wav b/tests/ref/TestOverload.wav index f22aa3c2..e831593c 100644 Binary files a/tests/ref/TestOverload.wav and b/tests/ref/TestOverload.wav differ