frac32 width
frac32 mix
frac32buffer in
frac32buffer out
frac32.u.map width
frac32.u.map mix
float32_t scaleback =
((float32_t)(1 << 27)) / ((float32_t)(param_width + inlet_width));
int32_t width0 = param_width + inlet_width;
int32_t width1 = (param_width + inlet_width) << 1;
int32_t width2 = (param_width + inlet_width) << 2;
int32_t mix = (param_mix + inlet_mix);
mix = mix > 0 ? mix : -mix;
mix = mix > (1 << 27) ? (2 << 27) - mix : mix;
int32_t miix = mix << 3;
mix = ((1 << 27) - mix) << 3;
int32_t shift = inlet_in + width0;
shift = shift > 0 ? shift : -shift;
int32_t wrap = shift - ((shift / width2) * width2);
int32_t bounce = wrap > width1 ? (width2 - wrap) : wrap;
outlet_out =
___SMMUL(miix, ((((int32_t)((bounce - width0) * scaleback))) << 2)) +
___SMMUL(mix, inlet_in << 2);