diff --git a/bse/bseresampler.hh b/bse/bseresampler.hh index 22c3ae434..ecd3ef575 100644 --- a/bse/bseresampler.hh +++ b/bse/bseresampler.hh @@ -83,6 +83,10 @@ public: * output[10] and output[11], and the second input sample equates output[11]. */ virtual double delay() const = 0; + /** + * clear internal history, reset resampler state to zero values + */ + virtual void reset() = 0; protected: static const double halfband_fir_linear_coeffs[2]; static const double halfband_fir_48db_coeffs[16]; diff --git a/bse/bseresamplerimpl.hh b/bse/bseresamplerimpl.hh index e8cf38685..10302008e 100644 --- a/bse/bseresamplerimpl.hh +++ b/bse/bseresamplerimpl.hh @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -296,7 +297,7 @@ public: void process_block (const float *input, guint n_input_samples, - float *output) + float *output) override { const uint history_todo = min (n_input_samples, ORDER - 1); @@ -320,15 +321,20 @@ public: * Returns the FIR filter order. */ guint - order() const + order() const override { return ORDER; } double - delay() const + delay() const override { return order() - 1; } + void + reset() override + { + Bse::Block::fill (history.size(), &history[0], 0.0); + } }; /** @@ -435,7 +441,7 @@ public: void process_block (const float *input, guint n_input_samples, - float *output) + float *output) override { BSE_ASSERT_RETURN ((n_input_samples & 1) == 0); @@ -497,15 +503,21 @@ public: * Returns the filter order. */ guint - order() const + order() const override { return ORDER; } double - delay() const + delay() const override { return order() / 2 - 0.5; } + void + reset() override + { + Bse::Block::fill (history_even.size(), &history_even[0], 0.0); + Bse::Block::fill (history_odd.size(), &history_odd[0], 0.0); + } }; template Resampler2*