1 #ifndef INCLUDE_AL_REVERB_HPP
2 #define INCLUDE_AL_REVERB_HPP
61 template <
int N,
class T>
67 static int size() {
return N; }
75 return (i <
size()) ? i : 0;
79 int pos()
const {
return mPos; }
82 const T&
read(
int i)
const {
84 if (ind < 0) ind +=
size();
93 if (mPos >=
size()) mPos = 0;
105 T
comb(
const T& v,
const T& ffd,
const T& fbk) {
114 T
allpass(
const T& v,
const T& ffd) {
return comb(v, ffd, -ffd); }
117 void zero() { ::memset(&mBuf, 0,
sizeof(mBuf)); }
132 template <
class T =
float>
147 mOPIn.damping(T(1) - v);
211 T v = mPreDelay(in * T(0.5));
213 v = mAPIn1.allpass(v, mDfIn1);
214 v = mAPIn2.allpass(v, mDfIn1);
215 v = mAPIn3.allpass(v, mDfIn2);
216 v = mAPIn4.allpass(v, mDfIn2);
218 T a = v + mDly22.back() * mDecay;
219 T b = v + mDly12.back() * mDecay;
221 a = mAPDecay11.allpass(a, -mDfDcy1);
223 a = mOP1(a) * mDecay;
224 a = mAPDecay12.allpass(a, mDfDcy2);
227 b = mAPDecay21.allpass(b, -mDfDcy1);
229 b = mOP2(b) * mDecay;
230 b = mAPDecay22.allpass(b, mDfDcy2);
233 out1 = (mDly21.read(266) + mDly21.read(2974) - mAPDecay22.read(1913) +
234 mDly22.read(1996) - mDly11.read(1990) - mAPDecay12.read(187) -
238 out2 = (mDly11.read(353) + mDly11.read(3627) - mAPDecay12.read(1228) +
239 mDly12.read(2673) - mDly21.read(2111) - mAPDecay22.read(335) -
250 T
mix(T& inout1, T& out2, T wetAmt) {
252 (*this)(s, inout1, out2, wetAmt * T(0.6));
280 OnePole() : mO1(0), mA0(1), mB1(0) {}
281 void damping(T v) { coef(v); }
283 mA0 = T(1) - std::abs(v);
286 T operator()(T i0) {
return mO1 = i0 * mA0 + mO1 * mB1; }
287 void zero() { mO1 = 0.0; }
293 T mDfIn1, mDfIn2, mDfDcy1, mDfDcy2, mDecay;
Reverb & diffusionIn2(T v)
Set input diffusion 2 amount, [0,1)
void operator()(T in, T &out1, T &out2, T gain=T(0.6))
Compute wet stereo output from dry mono input.
Reverb & diffusion(T in1, T in2, T decay1, T decay2)
Set diffusion amounts, in [0, 1)
Reverb & bandwidth(T v)
Set input signal bandwidth, in [0,1].
Reverb & damping(T v)
Set high-frequency damping amount, in [0, 1].
Reverb & diffusionDecay2(T v)
Set tank decay diffusion 2 amount, [0,1)
Reverb & decay(T v)
Set decay factor, in [0, 1)
T mix(T &inout1, T &out2, T wetAmt)
Compute wet/dry mix stereo output from dry mono input.
Reverb & diffusionDecay1(T v)
Set tank decay diffusion 1 amount, [0,1)
Reverb & diffusionIn1(T v)
Set input diffusion 1 amount, [0,1)
Delay-line whose maximum size is fixed.
const T & read(int i) const
Read value at delay i.
void zero()
Zeroes all elements (byte-wise)
int pos() const
Get absolute index of write tap.
T allpass(const T &v, const T &ffd)
static int size()
Get size of delay-line.
T operator()(const T &v)
Write new value and return oldest value.
int indexBack() const
Get index of back element.
const T & back() const
Get element at back.
T comb(const T &v, const T &ffd, const T &fbk)
void write(const T &v)
Write value to delay.