From f153def94194050b331c7a2674959b9ea1d0008d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 25 Dec 2019 18:39:22 -0800 Subject: Pass a span for the biquad filter input --- alc/filters/biquad.cpp | 8 +++----- alc/filters/biquad.h | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'alc/filters') 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::setParams(BiquadType type, Real f0norm, Real gain, Rea } template -void BiquadFilterR::process(Real *dst, const Real *src, const size_t numsamples) +void BiquadFilterR::process(const al::span src, Real *dst) { - ASSUME(numsamples > 0); - const Real b0{mB0}; const Real b1{mB1}; const Real b2{mB2}; @@ -111,12 +109,12 @@ void BiquadFilterR::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 #include +#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 src, Real *dst); /* Rather hacky. It's just here to support "manual" processing. */ std::pair 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; -- cgit v1.2.3