frac32buffer in
frac32 gain
frac32 feed
frac32 sub
frac32 srate
frac32 shifter
frac32 width
frac32 cutoff
frac32buffer out
int32.hradio mode
frac32.u.map gain
frac32.s.map feed
frac32.s.map sub
frac32.s.map shifter
frac32.s.map width
frac32.s.map.pitch srate
frac32.s.map.pitch cutoff
int32 stage
bool32.tgl svf
frac32.u.map.filterq resonance
int32_t val1;
int32_t val2;
int32_t val3;
int32_t feed;
int32_t sub;
int strig;
int32_t SUB;
int32_t low;
int32_t band;
int32_t dirac;
int32_t phase;
int32_t val4;
int32_t k[8];
int32_t p[8];
low = 0;
band = 0;
int32_t iS;
MTOFEXTENDED(param_srate + inlet_srate, iS)
int32_t iG = param_gain + inlet_gain;
int32_t Fi = param_feed + inlet_feed;
int32_t sU = param_sub + inlet_sub;
int32_t CUT;
MTOF(param_cutoff, CUT)
int32_t damp = (0x80 << 24) - (param_resonance << 3);
damp = ___SMMUL(damp, damp);
int32_t alpha;
int32_t FI;
MTOFEXTENDED(param_cutoff + inlet_cutoff, alpha);
SINE2TINTERP(alpha, FI);
int32_t Si = param_shifter + inlet_shifter;
int32_t iW = param_width + inlet_width;
k[0] = (iS - p[0]) >> 4;
int32_t sfrq = p[0];
p[0] = iS;
k[1] = (iG - p[1]) >> 4;
int32_t gain = p[1];
p[1] = iG;
k[2] = (Fi - p[2]) >> 4;
int32_t Feed = p[2];
p[2] = Fi;
k[3] = (sU - p[3]) >> 4;
int32_t SUb = p[3];
p[3] = sU;
k[4] = (CUT - p[4]) >> 4;
int32_t cut = p[4];
p[4] = CUT;
k[5] = (Si - p[5]) >> 4;
int32_t shifter = p[5];
p[5] = Si;
k[6] = (iW - p[6]) >> 4;
int32_t width = p[6];
p[6] = iW;
k[7] = (FI - p[7]) >> 4;
int32_t freq = p[7];
p[7] = FI;
sfrq += k[0];
gain += k[1];
Feed += k[2];
SUb += k[3];
cut += k[4];
shifter += k[5];
width += k[6];
freq += k[7];
int32_t in = (inlet_in >> 2) - feed;
int32_t rect = in > 0 ? in : -in;
val1 += (rect - val1) >> 11;
rect = rect - val1;
if ((inlet_in > 0) && !strig) {
sub = (sub + 1) & ((1 << param_stage) - 1);
strig = 1;
} else if (inlet_in < 0) {
strig = 0;
}
SUB = __SSAT((sub > (param_stage >> 1) ? 1 : -1) * sfrq + SUB, 27);
rect = __SSAT(___SMMUL(SUB << 3, SUb << 2) + rect, 27);
if (param_svf > 0) {
int32_t notch = rect - (___SMMUL(damp, band) << 1);
low = low + (___SMMUL(freq, band) << 1);
int32_t high = notch - low;
band = (___SMMUL(freq, high) << 1) + band;
if (param_mode == 0) {
rect = low;
}
if (param_mode == 1) {
rect = band;
}
}
if (param_svf == 0) {
val2 = ___SMMLA((rect - val2) << 1, cut, val2);
val3 = ___SMMLA((val2 - val3) << 1, cut, val3);
rect = val3;
}
rect += ___SMMUL((gain << 4) - (1 << 29), rect << 3);
// feed=___SMMUL(Feed<<2,rect<<2);
int32_t sine;
dirac = (rect - dirac);
phase += ___SMMUL(dirac << 8, shifter << 4);
SINE2TINTERP(phase, dirac)
dirac = ___SMMUL(dirac, width);
val4 += (dirac - val4) >> 9;
dirac = dirac - val4 << 1;
SINE2TINTERP((in + rect << 4) + dirac, sine)
sine = sine >> 5;
feed = ___SMMUL(Feed << 3, rect << 2);
outlet_out = sine;
dirac = rect;