aboutsummaryrefslogtreecommitdiffstats
path: root/alc/filters
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-12-25 21:48:58 -0800
committerChris Robinson <[email protected]>2019-12-25 21:48:58 -0800
commit3b3d3d3a03c3f39e758b3b9b41649b86314eb413 (patch)
treeac65877d89e9fc97b79ac0fcd83a290d825f4247 /alc/filters
parent06b7c63cef00a9641e7e36d972fdc3c0c78ca4b8 (diff)
Use a span for the band-splitter input
Diffstat (limited to 'alc/filters')
-rw-r--r--alc/filters/splitter.cpp22
-rw-r--r--alc/filters/splitter.h8
2 files changed, 14 insertions, 16 deletions
diff --git a/alc/filters/splitter.cpp b/alc/filters/splitter.cpp
index c6218e70..e8e01802 100644
--- a/alc/filters/splitter.cpp
+++ b/alc/filters/splitter.cpp
@@ -27,10 +27,8 @@ void BandSplitterR<Real>::init(Real f0norm)
}
template<typename Real>
-void BandSplitterR<Real>::process(Real *hpout, Real *lpout, const Real *input, const size_t count)
+void BandSplitterR<Real>::process(const al::span<const Real> input, Real *hpout, Real *lpout)
{
- ASSUME(count > 0);
-
const Real ap_coeff{mCoeff};
const Real lp_coeff{mCoeff*0.5f + 0.5f};
Real lp_z1{mLpZ1};
@@ -56,17 +54,15 @@ void BandSplitterR<Real>::process(Real *hpout, Real *lpout, const Real *input, c
/* High-pass generated from removing low-passed output. */
return ap_y - lp_y;
};
- std::transform(input, input+count, hpout, proc_sample);
+ std::transform(input.cbegin(), input.cend(), hpout, proc_sample);
mLpZ1 = lp_z1;
mLpZ2 = lp_z2;
mApZ1 = ap_z1;
}
template<typename Real>
-void BandSplitterR<Real>::applyHfScale(Real *samples, const Real hfscale, const size_t count)
+void BandSplitterR<Real>::applyHfScale(const al::span<Real> samples, const Real hfscale)
{
- ASSUME(count > 0);
-
const Real ap_coeff{mCoeff};
const Real lp_coeff{mCoeff*0.5f + 0.5f};
Real lp_z1{mLpZ1};
@@ -87,20 +83,20 @@ void BandSplitterR<Real>::applyHfScale(Real *samples, const Real hfscale, const
Real ap_y{in*ap_coeff + ap_z1};
ap_z1 = in - ap_y*ap_coeff;
- /* High-pass generated from removing low-passed output. */
+ /* High-pass generated by removing the low-passed signal, which is then
+ * scaled and added back to the low-passed signal.
+ */
return (ap_y-lp_y)*hfscale + lp_y;
};
- std::transform(samples, samples+count, samples, proc_sample);
+ std::transform(samples.begin(), samples.end(), samples.begin(), proc_sample);
mLpZ1 = lp_z1;
mLpZ2 = lp_z2;
mApZ1 = ap_z1;
}
template<typename Real>
-void BandSplitterR<Real>::applyAllpass(Real *samples, const size_t count) const
+void BandSplitterR<Real>::applyAllpass(const al::span<Real> samples) const
{
- ASSUME(count > 0);
-
const Real coeff{mCoeff};
Real z1{0.0f};
auto proc_sample = [coeff,&z1](const Real in) noexcept -> Real
@@ -109,7 +105,7 @@ void BandSplitterR<Real>::applyAllpass(Real *samples, const size_t count) const
z1 = in - out*coeff;
return out;
};
- std::transform(samples, samples+count, samples, proc_sample);
+ std::transform(samples.begin(), samples.end(), samples.begin(), proc_sample);
}
diff --git a/alc/filters/splitter.h b/alc/filters/splitter.h
index 5117a244..d88ef182 100644
--- a/alc/filters/splitter.h
+++ b/alc/filters/splitter.h
@@ -3,6 +3,8 @@
#include <cstddef>
+#include "alspan.h"
+
/* Band splitter. Splits a signal into two phase-matching frequency bands. */
template<typename Real>
@@ -19,15 +21,15 @@ public:
void init(Real f0norm);
void clear() noexcept { mLpZ1 = mLpZ2 = mApZ1 = 0.0f; }
- void process(Real *hpout, Real *lpout, const Real *input, const size_t count);
+ void process(const al::span<const Real> input, Real *hpout, Real *lpout);
- void applyHfScale(Real *samples, const Real hfscale, const size_t count);
+ void applyHfScale(const al::span<Real> samples, const Real hfscale);
/* The all-pass portion of the band splitter. Applies the same phase shift
* without splitting the signal. Note that each use of this method is
* indepedent, it does not track history between calls.
*/
- void applyAllpass(Real *samples, const size_t count) const;
+ void applyAllpass(const al::span<Real> samples) const;
};
using BandSplitter = BandSplitterR<float>;