diff options
author | Chris Robinson <[email protected]> | 2019-12-25 18:39:22 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-12-25 18:39:22 -0800 |
commit | f153def94194050b331c7a2674959b9ea1d0008d (patch) | |
tree | 17012f29ae0f51ebf615a3866210bba2b8636652 /alc/filters | |
parent | 36c745a5149fe196b2ea8c058d2d3391db3dde8b (diff) |
Pass a span for the biquad filter input
Diffstat (limited to 'alc/filters')
-rw-r--r-- | alc/filters/biquad.cpp | 8 | ||||
-rw-r--r-- | alc/filters/biquad.h | 5 |
2 files changed, 6 insertions, 7 deletions
diff --git a/alc/filters/biquad.cpp b/alc/filters/biquad.cpp index 13cbca3f..271ca696 100644 --- a/alc/filters/biquad.cpp +++ b/alc/filters/biquad.cpp @@ -89,10 +89,8 @@ void BiquadFilterR<Real>::setParams(BiquadType type, Real f0norm, Real gain, Rea } template<typename Real> -void BiquadFilterR<Real>::process(Real *dst, const Real *src, const size_t numsamples) +void BiquadFilterR<Real>::process(const al::span<const Real> src, Real *dst) { - ASSUME(numsamples > 0); - const Real b0{mB0}; const Real b1{mB1}; const Real b2{mB2}; @@ -111,12 +109,12 @@ void BiquadFilterR<Real>::process(Real *dst, const Real *src, const size_t numsa */ auto proc_sample = [b0,b1,b2,a1,a2,&z1,&z2](Real input) noexcept -> Real { - Real output = input*b0 + z1; + const Real output{input*b0 + z1}; z1 = input*b1 - output*a1 + z2; z2 = input*b2 - output*a2; return output; }; - std::transform(src, src+numsamples, dst, proc_sample); + std::transform(src.cbegin(), src.cend(), dst, proc_sample); mZ1 = z1; mZ2 = z2; diff --git a/alc/filters/biquad.h b/alc/filters/biquad.h index a8bc86e7..30eed57d 100644 --- a/alc/filters/biquad.h +++ b/alc/filters/biquad.h @@ -6,6 +6,7 @@ #include <cstddef> #include <utility> +#include "alspan.h" #include "math_defs.h" @@ -114,14 +115,14 @@ public: } - void process(Real *dst, const Real *src, const size_t numsamples); + void process(const al::span<const Real> src, Real *dst); /* Rather hacky. It's just here to support "manual" processing. */ std::pair<Real,Real> getComponents() const noexcept { return {mZ1, mZ2}; } void setComponents(Real z1, Real z2) noexcept { mZ1 = z1; mZ2 = z2; } Real processOne(const Real in, Real &z1, Real &z2) const noexcept { - Real out{in*mB0 + z1}; + const Real out{in*mB0 + z1}; z1 = in*mB1 - out*mA1 + z2; z2 = in*mB2 - out*mA2; return out; |