mostFilter3

My own filter, with a filtering based on the workings of "gravity". This version has limiters/distortions added in both the normal filter path as well as the "resonance" path (the rate at which the filter can respond) and also just before the filter to prevent errors caused by "too hot levels". -first stage: soft-clipping (native soft-distortion algorithm) -second stage: adding an extra 6dB LP-filter. Note though, that this has another effect when in HP-mode, actually adding back bass to the HP-filter because of phase-differences caused by the 2-sample delay. -third stage: calculating the rate-in/decrease based on input and current filter position -fourth stage: limiting the rate -fifth stage: applying rate to filter -sixth stage: limiting the filter -seventh stage: optionally adding inversed input signal to filter to get HP-mode. The "treshold" limiter is a hard-clipper. The "drive" subtracts a 3rd degree power from the signal to limit it's range. Because of the curve, it has a bit softer distortion then the hard limiter.
Author: Remco van der Most
License: BSD
Github: sss/filter/mostfilter3.axo

Inlets

frac32buffer in

frac32 cut

frac32 res

Outlets

frac32buffer out

frac32buffer res

Parameters

frac32.u.map res

frac32.u.map Rdrive

frac32.u.map Ftreshold

frac32.u.map Rtreshold

frac32.u.map.gain Fdrive

frac32.u.map.gain slope

bool32.tgl hp

frac32.s.map.pitch cut

Declaration
int32_t pos;
int32_t spd;
int32_t v27 = 1 << 27;
int32_t prv;
int32_t th;
int32_t lp;
Control Rate
int32_t frq;
MTOF(param_cut + inlet_cut, frq)
frq = frq >> 1;
int32_t damp = (int32_t)((v27 - __USAT(param_res + inlet_res, 27) * 0.99)) << 3;
int32_t Damp = (int32_t)(v27 - ((v27 - __USAT(param_Rdrive, 27) * 0.99))) << 3;
int32_t Rtreshold = param_Rtreshold;
Rtreshold = ___SMMUL(Rtreshold << 3, Rtreshold << 2);
int32_t Ftreshold = param_Ftreshold << 1;
Audio Rate
int32_t in;
int32_t ts = __SSAT(inlet_in, 28);
int32_t tsq31 = ts << 3;
int32_t tsq31p3 = ___SMMUL(tsq31, ___SMMUL(tsq31, tsq31));
in = ts + (ts >> 1) - (tsq31p3);
lp += ___SMMUL((in - lp) << 1, frq << 1) << 1;
int32_t Tmp;
if (param_hp == 0) {
  Tmp = lp - in;
} else if (param_hp == 1) {
  Tmp = -lp;
}
int32_t LP = in + (___SMMUL(Tmp, param_slope));
spd += ___SMMUL((LP - pos), frq) << 3;
int32_t tmp = ___SMMUL(spd, __USAT(Damp, 30)) << 1;
spd -= ___SMMUL(tmp, ___SMMUL(tmp, tmp) << 5) << 7;
th = spd;
th = th > 0 ? th : -th;
th = th > Rtreshold ? __USAT(th - Rtreshold, 26) << 4 : 0;
spd -= ___SMMUL(spd, __USAT(th, 30));
pos += spd;

th = pos;
th = th > 0 ? th : -th;
th = th > Ftreshold ? __USAT(th - Ftreshold, 26) << 4 : 0;
pos -= ___SMMUL(pos, __USAT(th, 30));
int32_t dp = LP - pos;
dp = dp > 0 ? dp : -dp;
dp = ___SMMUL(dp, param_Fdrive) << 1;
dp = ___SMMUL(dp, ___SMMUL(dp, dp) << 5) << 5;
pos -= ___SMMUL(pos, __USAT(dp, 26)) << 5;
pos -= ___SMMUL(pos, __USAT(damp, 30));

outlet_out = pos - (param_hp > 0 ? in : 0);
outlet_res = -(spd - prv) << 1;
prv = spd;

Privacy

© 2024 Zrna Research