frac32buffer i1
frac32 rate
frac32 slope
frac32 amt
frac32 tresh
frac32buffer o1
frac32.s.map rate
frac32.s.map slope
frac32.u.map amt
frac32.u.map tresh
int32_t val;
int32_t vel;
int32_t f1;
int32_t f2;
MTOF(param_slope + param_rate + inlet_slope + inlet_rate, f1)
MTOF(-param_slope + param_rate - inlet_slope + inlet_rate, f2)
f1 = f1;
f2 = f2;
int32_t tresh = __USAT(param_tresh + inlet_tresh + 4, 27);
tresh = ___SMMUL(tresh << 3, tresh << 2);
tresh = ___SMMUL(tresh << 3, tresh << 2);
int32_t amt = __USAT(param_amt + inlet_amt, 27);
if ((inlet_i1 / tresh) & 1) {
if (inlet_i1 > 0) {
val += f1;
val = val > amt ? amt : val;
} else {
val -= f2;
val = val < -amt ? -amt : val;
}
}
vel += val - vel >> 2;
outlet_o1 = inlet_i1 - (vel >> 2);