frac32buffer in
frac32 cutoff
frac32 reso
frac32 center
frac32 width
frac32buffer out
frac32.s.map.pitch cutoff
frac32.s.map center
frac32.s.map peak
frac32.u.map width
frac32.u.map.filterq resoHP
frac32.u.map.filterq resoLP
frac32.u.map.filterq resoPeak
int32_t out;
int32_t low[3];
int32_t band[3];
int32_t notch;
int32_t high;
int32_t freq[3];
int32_t res[3];
int32_t COEF(int32_t F, int32_t R, int I) {
res[I] = (0x80 << 24) - (R << 4);
res[I] = ___SMMUL(res[I], res[I]);
int32_t alpha;
MTOFEXTENDED(F, alpha);
SINE2TINTERP(alpha, freq[I]);
}
int32_t SVF(int32_t IN, int I) {
band[I] -= ___SMMUL(___SMMUL(band[I] << 2, band[I] << 2), band[I] << 2);
notch = IN - (___SMMUL(res[I], band[I]) << 1);
low[I] = low[I] + (___SMMUL(freq[I], band[I]) << 1);
high = notch - low[I];
band[I] = (___SMMUL(freq[I], high) << 1) + band[I];
}
int32_t SOFT(int32_t in) {
int32_t ts = __SSAT(in, 28);
int32_t tsq31 = ts << 3;
int32_t tsq31p3 = ___SMMUL(tsq31, ___SMMUL(tsq31, tsq31));
return out = ts + (ts >> 1) - (tsq31p3);
}
int32_t width = __SSAT(inlet_width + param_width, 28);
int32_t cutoff = param_cutoff + inlet_cutoff;
COEF(__SSAT(cutoff +
(___SMMUL(__SSAT(param_center + inlet_center, 28), width) << 5),
28),
param_resoPeak, 0);
COEF(__SSAT(cutoff + width, 28), param_resoLP, 1);
COEF(__SSAT(cutoff - width, 28), param_resoHP, 2);
SVF(inlet_in >> 1, 0);
SVF(SOFT((inlet_in >> 1) + (___SMMUL(band[0], param_peak << 4) << 1)), 1);
SVF(SOFT(low[1]), 2);
outlet_out = SOFT(high);