10 #include "math_defs.h"
12 template<typename Real
>
13 void BandSplitterR
<Real
>::init(Real f0norm
)
15 const Real w
{f0norm
* al::MathDefs
<Real
>::Tau()};
16 const Real cw
{std::cos(w
)};
17 if(cw
> std::numeric_limits
<float>::epsilon())
18 coeff
= (std::sin(w
) - 1.0f
) / cw
;
27 template<typename Real
>
28 void BandSplitterR
<Real
>::process(Real
*RESTRICT hpout
, Real
*RESTRICT lpout
, const Real
*input
, int count
)
32 const Real ap_coeff
{this->coeff
};
33 const Real lp_coeff
{this->coeff
*0.5f
+ 0.5f
};
34 Real lp_z1
{this->lp_z1
};
35 Real lp_z2
{this->lp_z2
};
36 Real ap_z1
{this->ap_z1
};
37 auto proc_sample
= [ap_coeff
,lp_coeff
,&lp_z1
,&lp_z2
,&ap_z1
,&lpout
](const Real in
) noexcept
-> Real
39 /* Low-pass sample processing. */
40 Real d
{(in
- lp_z1
) * lp_coeff
};
44 d
= (lp_y
- lp_z2
) * lp_coeff
;
50 /* All-pass sample processing. */
51 Real ap_y
{in
*ap_coeff
+ ap_z1
};
52 ap_z1
= in
- ap_y
*ap_coeff
;
54 /* High-pass generated from removing low-passed output. */
57 std::transform(input
, input
+count
, hpout
, proc_sample
);
63 template class BandSplitterR
<float>;
64 template class BandSplitterR
<double>;
67 template<typename Real
>
68 void SplitterAllpassR
<Real
>::init(Real f0norm
)
70 const Real w
{f0norm
* al::MathDefs
<Real
>::Tau()};
71 const Real cw
{std::cos(w
)};
72 if(cw
> std::numeric_limits
<float>::epsilon())
73 coeff
= (std::sin(w
) - 1.0f
) / cw
;
80 template<typename Real
>
81 void SplitterAllpassR
<Real
>::process(Real
*RESTRICT samples
, int count
)
85 const Real coeff
{this->coeff
};
87 auto proc_sample
= [coeff
,&z1
](const Real in
) noexcept
-> Real
89 Real out
{in
*coeff
+ z1
};
93 std::transform(samples
, samples
+count
, samples
, proc_sample
);
97 template class SplitterAllpassR
<float>;
98 template class SplitterAllpassR
<double>;