10 #include "math_defs.h"
11 #include "opthelpers.h"
14 template<typename Real
>
15 void BandSplitterR
<Real
>::init(Real f0norm
)
17 const Real w
{f0norm
* al::MathDefs
<Real
>::Tau()};
18 const Real cw
{std::cos(w
)};
19 if(cw
> std::numeric_limits
<float>::epsilon())
20 mCoeff
= (std::sin(w
) - 1.0f
) / cw
;
29 template<typename Real
>
30 void BandSplitterR
<Real
>::process(Real
*hpout
, Real
*lpout
, const Real
*input
, const size_t count
)
34 const Real ap_coeff
{mCoeff
};
35 const Real lp_coeff
{mCoeff
*0.5f
+ 0.5f
};
39 auto proc_sample
= [ap_coeff
,lp_coeff
,&lp_z1
,&lp_z2
,&ap_z1
,&lpout
](const Real in
) noexcept
-> Real
41 /* Low-pass sample processing. */
42 Real d
{(in
- lp_z1
) * lp_coeff
};
46 d
= (lp_y
- lp_z2
) * lp_coeff
;
52 /* All-pass sample processing. */
53 Real ap_y
{in
*ap_coeff
+ ap_z1
};
54 ap_z1
= in
- ap_y
*ap_coeff
;
56 /* High-pass generated from removing low-passed output. */
59 std::transform(input
, input
+count
, hpout
, proc_sample
);
65 template<typename Real
>
66 void BandSplitterR
<Real
>::applyHfScale(Real
*samples
, const Real hfscale
, const size_t count
)
70 const Real ap_coeff
{mCoeff
};
71 const Real lp_coeff
{mCoeff
*0.5f
+ 0.5f
};
75 auto proc_sample
= [hfscale
,ap_coeff
,lp_coeff
,&lp_z1
,&lp_z2
,&ap_z1
](const Real in
) noexcept
-> Real
77 /* Low-pass sample processing. */
78 Real d
{(in
- lp_z1
) * lp_coeff
};
82 d
= (lp_y
- lp_z2
) * lp_coeff
;
86 /* All-pass sample processing. */
87 Real ap_y
{in
*ap_coeff
+ ap_z1
};
88 ap_z1
= in
- ap_y
*ap_coeff
;
90 /* High-pass generated from removing low-passed output. */
91 return (ap_y
-lp_y
)*hfscale
+ lp_y
;
93 std::transform(samples
, samples
+count
, samples
, proc_sample
);
99 template<typename Real
>
100 void BandSplitterR
<Real
>::applyAllpass(Real
*samples
, const size_t count
) const
104 const Real coeff
{mCoeff
};
106 auto proc_sample
= [coeff
,&z1
](const Real in
) noexcept
-> Real
108 const Real out
{in
*coeff
+ z1
};
112 std::transform(samples
, samples
+count
, samples
, proc_sample
);
116 template class BandSplitterR
<float>;
117 template class BandSplitterR
<double>;