diff --git a/include/dsp/resampler.hpp b/include/dsp/resampler.hpp index d3646157..82d5ab5c 100644 --- a/include/dsp/resampler.hpp +++ b/include/dsp/resampler.hpp @@ -103,9 +103,9 @@ struct SampleRateConverter { /** Downsamples by an integer factor. */ -template +template struct Decimator { - float inBuffer[OVERSAMPLE*QUALITY]; + T inBuffer[OVERSAMPLE*QUALITY]; float kernel[OVERSAMPLE*QUALITY]; int inIndex; @@ -119,14 +119,14 @@ struct Decimator { std::memset(inBuffer, 0, sizeof(inBuffer)); } /** `in` must be length OVERSAMPLE */ - float process(float *in) { + T process(T *in) { // Copy input to buffer - std::memcpy(&inBuffer[inIndex], in, OVERSAMPLE*sizeof(float)); + std::memcpy(&inBuffer[inIndex], in, OVERSAMPLE*sizeof(T)); // Advance index inIndex += OVERSAMPLE; inIndex %= OVERSAMPLE*QUALITY; // Perform naive convolution - float out = 0.f; + T out = 0.f; for (int i = 0; i < OVERSAMPLE*QUALITY; i++) { int index = inIndex - 1 - i; index = (index + OVERSAMPLE*QUALITY) % (OVERSAMPLE*QUALITY); diff --git a/include/simd/functions.hpp b/include/simd/functions.hpp index 0f4cdac8..9d2ee86f 100644 --- a/include/simd/functions.hpp +++ b/include/simd/functions.hpp @@ -123,7 +123,7 @@ inline float_4 pow(float a, float_4 b) { template T pow(T a, int b) { - // Optimal with `-O3 -ffast-math` when b is known at compile-time + // Optimal with `-O3 -funsafe-math-optimizations` when b is known at compile-time T p = 1; for (int i = 1; i <= b; i *= 2) { if (i & b)