frac32buffer filter input
frac32 pitch1
frac32 Pspread
frac32 reso1
frac32 rate
frac32 spread
frac32 depth
frac32 phase
frac32buffer filter output
frac32.u.map.filterq reso1
int32.hradio mode
int32 stack
frac32.s.map.pitch pitch1
frac32.s.map Pspread
frac32.s.map rate
frac32.s.map spread
frac32.s.map depth
int32_t low[16];
int32_t band[16];
int32_t OUT[16];
int32_t freq[16];
int32_t Damp[16];
int32_t IN[17];
int32_t LFO;
int32_t sym;
int i;
int mode;
int32_t config(int32_t pitch, int32_t reso, int Inst) {
int32_t damp = (0x80 << 24) - (reso << 4);
damp = ___SMMUL(damp, damp);
Damp[Inst] = damp;
int32_t alpha;
MTOFEXTENDED(pitch, alpha);
SINE2TINTERP(alpha, freq[Inst]);
}
int32_t SVF(int32_t in1, int32_t Freq, int32_t damp, int32_t Inst,
int32_t stack) {
if (mode > 1) {
in1 = IN[0];
}
int32_t notch = in1 - __SSAT((___SMMUL(damp, band[Inst]) << 1), 27);
low[Inst] = low[Inst] + __SSAT((___SMMUL(Freq, band[Inst]) << 1), 27);
int32_t high = notch - low[Inst];
band[Inst] = (___SMMUL(Freq, high) << 1) + __SSAT(band[Inst], 27);
if (mode == 0) {
IN[Inst + 1] = in1 - band[Inst];
}
if (mode == 1) {
IN[Inst + 1] = in1 + band[Inst] / 5 * 3;
}
if (mode == 2) {
IN[Inst + 1] = in1 - band[Inst];
}
if (mode == 3) {
IN[Inst + 1] = in1 + band[Inst] / 5 * 3;
}
}
for (i = 0; i < 2; i++) {
low[i] = 0;
band[i] = 0;
}
int32_t rate;
MTOFEXTENDED(param_rate + inlet_rate, rate)
mode = param_mode;
LFO += rate >> 6;
for (i = 0; i < param_stack; i++) {
int32_t lfo =
LFO + inlet_phase +
(((param_spread + inlet_spread) << 4) / (param_stack)*i << 2) >>
4;
lfo = lfo > 0 ? lfo : -lfo;
lfo = ___SMMUL((param_depth + inlet_depth) << 3, lfo << 2);
int32_t PITCH = inlet_pitch1 + param_pitch1 + lfo +
(((param_Pspread + inlet_Pspread)) / (param_stack)*i);
PITCH = PITCH > (1 << 27) ? (1 << 28) - PITCH : PITCH;
PITCH = PITCH < (-1 << 27) ? (-1 << 28) + PITCH : PITCH;
config(PITCH, __USAT(param_reso1 + inlet_reso1, 27), i);
}
IN[0] = inlet_in1;
for (i = 0; i < param_stack; i++) {
SVF(IN[i], freq[i], Damp[i], i, param_stack);
}
sym = IN[param_stack];
if (mode > 1) {
sym = 0;
for (i = 0; i < param_stack; i++) {
sym += IN[i + 1];
}
}
outlet_out = (sym >> 1);