mostfilter2nd

2nd order "most" filter with continuous mode selection lp->bp->hp
Author: Remco van der Most
License: BSD
Github: sss/filter/mostfilter2nd.axo

Inlets

frac32 tame

frac32buffer audio input

frac32.bipolar cutoff frequency

frac32.bipolar resonance/damp amount

frac32.positive continuous lp/bp/hp mode selection

Outlets

frac32buffer audio output

Parameters

frac32.s.map.pitch cutoff frequency

frac32.s.map resonance/damping amount

frac32.u.map continuous lp/bp/hp mode selection

frac32.u.map tame

Declaration
int32_t val1, val2;
int32_t r1, r2;
int32_t prv1, prv2, stp1, stp2, tm, md;
Init
r1 = r2 = val2 = val1 = 0;
Control Rate
int32_t f;
int32_t pitch = param_freq + inlet_freq;
MTOF(pitch, f);
int32_t damp;
damp = __SSAT(param_damp + inlet_damp, 28);
MTOF(__SSAT(-damp + pitch - (1 << 25), 28), damp)
damp = damp;
int32_t mode = __USAT(param_mode + inlet_mode, 27);

int32_t tame = __USAT(param_tame + inlet_tame, 27);

stp1 = tame - prv1 >> 4;
tm = prv1;
prv1 = tame;
stp2 = mode - prv2 >> 4;
md = prv2;
prv2 = mode;
Audio Rate
int32_t in = inlet_in;
int32_t mix1 = __USAT(md, 26);
int32_t mix2 = md - mix1 << 4;
mix1 = mix1 << 4;
in += ___SMMUL(__SSAT(val1 + val2, 28), tm) << 3;

r1 += ___SMMUL(in - val1 << 1, f);
r1 -= ___SMMUL(r1, damp) << 1;
r1 -= r1 >> 7;
val1 = ___SMMLA(r1, f, val1);
int32_t tmp = val1 - (___SMMUL(in, mix2) << 2);
r2 += ___SMMUL(tmp - val2, f) << 1;
r2 -= ___SMMUL(r2, damp) << 1;
r2 -= r2 >> 7;
val2 = ___SMMLA(r2, f, val2);
outlet_out = val2 - (___SMMUL(mix1, tmp) << 2);
val1 = __SSAT(val1, 28);
val2 = __SSAT(val2, 28);
tm += stp1;
md += stp2;

Privacy

© 2024 Zrna Research