diff options
author | Chris Robinson <[email protected]> | 2019-09-14 18:27:57 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-09-14 18:35:23 -0700 |
commit | 807d3b64cac2793ce678acb3fc4d4191b2252875 (patch) | |
tree | b766e0838c75fcf069015078259c5bfbd56bce63 /alc/filters | |
parent | 2cc0600476fc4ed13a64eeb59c02c213bd3b6dd4 (diff) |
Enable and fix more warnings
Diffstat (limited to 'alc/filters')
-rw-r--r-- | alc/filters/biquad.cpp | 28 | ||||
-rw-r--r-- | alc/filters/biquad.h | 32 | ||||
-rw-r--r-- | alc/filters/splitter.cpp | 44 | ||||
-rw-r--r-- | alc/filters/splitter.h | 10 |
4 files changed, 56 insertions, 58 deletions
diff --git a/alc/filters/biquad.cpp b/alc/filters/biquad.cpp index a4d81604..8a8810e2 100644 --- a/alc/filters/biquad.cpp +++ b/alc/filters/biquad.cpp @@ -81,11 +81,11 @@ void BiquadFilterR<Real>::setParams(BiquadType type, Real gain, Real f0norm, Rea break; } - a1 = a[1] / a[0]; - a2 = a[2] / a[0]; - b0 = b[0] / a[0]; - b1 = b[1] / a[0]; - b2 = b[2] / a[0]; + mA1 = a[1] / a[0]; + mA2 = a[2] / a[0]; + mB0 = b[0] / a[0]; + mB1 = b[1] / a[0]; + mB2 = b[2] / a[0]; } template<typename Real> @@ -93,13 +93,13 @@ void BiquadFilterR<Real>::process(Real *dst, const Real *src, const size_t numsa { ASSUME(numsamples > 0); - const Real b0{this->b0}; - const Real b1{this->b1}; - const Real b2{this->b2}; - const Real a1{this->a1}; - const Real a2{this->a2}; - Real z1{this->z1}; - Real z2{this->z2}; + const Real b0{mB0}; + const Real b1{mB1}; + const Real b2{mB2}; + const Real a1{mA1}; + const Real a2{mA2}; + Real z1{mZ1}; + Real z2{mZ2}; /* Processing loop is Transposed Direct Form II. This requires less storage * compared to Direct Form I (only two delay components, instead of a four- @@ -118,8 +118,8 @@ void BiquadFilterR<Real>::process(Real *dst, const Real *src, const size_t numsa }; std::transform(src, src+numsamples, dst, proc_sample); - this->z1 = z1; - this->z2 = z2; + mZ1 = z1; + mZ2 = z2; } template class BiquadFilterR<float>; diff --git a/alc/filters/biquad.h b/alc/filters/biquad.h index 9de86f2f..9af954ae 100644 --- a/alc/filters/biquad.h +++ b/alc/filters/biquad.h @@ -38,14 +38,14 @@ enum class BiquadType { template<typename Real> class BiquadFilterR { /* Last two delayed components for direct form II. */ - Real z1{0.0f}, z2{0.0f}; + Real mZ1{0.0f}, mZ2{0.0f}; /* Transfer function coefficients "b" (numerator) */ - Real b0{1.0f}, b1{0.0f}, b2{0.0f}; + Real mB0{1.0f}, mB1{0.0f}, mB2{0.0f}; /* Transfer function coefficients "a" (denominator; a0 is pre-applied). */ - Real a1{0.0f}, a2{0.0f}; + Real mA1{0.0f}, mA2{0.0f}; public: - void clear() noexcept { z1 = z2 = 0.0f; } + void clear() noexcept { mZ1 = mZ2 = 0.0f; } /** * Sets the filter state for the specified filter type and its parameters. @@ -65,26 +65,24 @@ public: void copyParamsFrom(const BiquadFilterR &other) { - b0 = other.b0; - b1 = other.b1; - b2 = other.b2; - a1 = other.a1; - a2 = other.a2; + mB0 = other.mB0; + mB1 = other.mB1; + mB2 = other.mB2; + mA1 = other.mA1; + mA2 = other.mA2; } void process(Real *dst, const Real *src, const size_t numsamples); /* Rather hacky. It's just here to support "manual" processing. */ - std::pair<Real,Real> getComponents() const noexcept - { return {z1, z2}; } - void setComponents(Real z1_, Real z2_) noexcept - { z1 = z1_; z2 = z2_; } - Real processOne(const Real in, Real &z1_, Real &z2_) const noexcept + 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*b0 + z1_}; - z1_ = in*b1 - out*a1 + z2_; - z2_ = in*b2 - out*a2; + Real out{in*mB0 + z1}; + z1 = in*mB1 - out*mA1 + z2; + z2 = in*mB2 - out*mA2; return out; } diff --git a/alc/filters/splitter.cpp b/alc/filters/splitter.cpp index 66806ea9..c6218e70 100644 --- a/alc/filters/splitter.cpp +++ b/alc/filters/splitter.cpp @@ -17,13 +17,13 @@ void BandSplitterR<Real>::init(Real f0norm) const Real w{f0norm * al::MathDefs<Real>::Tau()}; const Real cw{std::cos(w)}; if(cw > std::numeric_limits<float>::epsilon()) - coeff = (std::sin(w) - 1.0f) / cw; + mCoeff = (std::sin(w) - 1.0f) / cw; else - coeff = cw * -0.5f; + mCoeff = cw * -0.5f; - lp_z1 = 0.0f; - lp_z2 = 0.0f; - ap_z1 = 0.0f; + mLpZ1 = 0.0f; + mLpZ2 = 0.0f; + mApZ1 = 0.0f; } template<typename Real> @@ -31,11 +31,11 @@ void BandSplitterR<Real>::process(Real *hpout, Real *lpout, const Real *input, c { ASSUME(count > 0); - const Real ap_coeff{this->coeff}; - const Real lp_coeff{this->coeff*0.5f + 0.5f}; - Real lp_z1{this->lp_z1}; - Real lp_z2{this->lp_z2}; - Real ap_z1{this->ap_z1}; + const Real ap_coeff{mCoeff}; + const Real lp_coeff{mCoeff*0.5f + 0.5f}; + Real lp_z1{mLpZ1}; + Real lp_z2{mLpZ2}; + Real ap_z1{mApZ1}; auto proc_sample = [ap_coeff,lp_coeff,&lp_z1,&lp_z2,&ap_z1,&lpout](const Real in) noexcept -> Real { /* Low-pass sample processing. */ @@ -57,9 +57,9 @@ void BandSplitterR<Real>::process(Real *hpout, Real *lpout, const Real *input, c return ap_y - lp_y; }; std::transform(input, input+count, hpout, proc_sample); - this->lp_z1 = lp_z1; - this->lp_z2 = lp_z2; - this->ap_z1 = ap_z1; + mLpZ1 = lp_z1; + mLpZ2 = lp_z2; + mApZ1 = ap_z1; } template<typename Real> @@ -67,11 +67,11 @@ void BandSplitterR<Real>::applyHfScale(Real *samples, const Real hfscale, const { ASSUME(count > 0); - const Real ap_coeff{this->coeff}; - const Real lp_coeff{this->coeff*0.5f + 0.5f}; - Real lp_z1{this->lp_z1}; - Real lp_z2{this->lp_z2}; - Real ap_z1{this->ap_z1}; + const Real ap_coeff{mCoeff}; + const Real lp_coeff{mCoeff*0.5f + 0.5f}; + Real lp_z1{mLpZ1}; + Real lp_z2{mLpZ2}; + Real ap_z1{mApZ1}; auto proc_sample = [hfscale,ap_coeff,lp_coeff,&lp_z1,&lp_z2,&ap_z1](const Real in) noexcept -> Real { /* Low-pass sample processing. */ @@ -91,9 +91,9 @@ void BandSplitterR<Real>::applyHfScale(Real *samples, const Real hfscale, const return (ap_y-lp_y)*hfscale + lp_y; }; std::transform(samples, samples+count, samples, proc_sample); - this->lp_z1 = lp_z1; - this->lp_z2 = lp_z2; - this->ap_z1 = ap_z1; + mLpZ1 = lp_z1; + mLpZ2 = lp_z2; + mApZ1 = ap_z1; } template<typename Real> @@ -101,7 +101,7 @@ void BandSplitterR<Real>::applyAllpass(Real *samples, const size_t count) const { ASSUME(count > 0); - const Real coeff{this->coeff}; + const Real coeff{mCoeff}; Real z1{0.0f}; auto proc_sample = [coeff,&z1](const Real in) noexcept -> Real { diff --git a/alc/filters/splitter.h b/alc/filters/splitter.h index b024f0c3..5117a244 100644 --- a/alc/filters/splitter.h +++ b/alc/filters/splitter.h @@ -7,10 +7,10 @@ /* Band splitter. Splits a signal into two phase-matching frequency bands. */ template<typename Real> class BandSplitterR { - Real coeff{0.0f}; - Real lp_z1{0.0f}; - Real lp_z2{0.0f}; - Real ap_z1{0.0f}; + Real mCoeff{0.0f}; + Real mLpZ1{0.0f}; + Real mLpZ2{0.0f}; + Real mApZ1{0.0f}; public: BandSplitterR() = default; @@ -18,7 +18,7 @@ public: BandSplitterR(Real f0norm) { init(f0norm); } void init(Real f0norm); - void clear() noexcept { lp_z1 = lp_z2 = ap_z1 = 0.0f; } + void clear() noexcept { mLpZ1 = mLpZ2 = mApZ1 = 0.0f; } void process(Real *hpout, Real *lpout, const Real *input, const size_t count); void applyHfScale(Real *samples, const Real hfscale, const size_t count); |