frac32 in
bool32 glideOFF
frac32 out
frac32.u.map glide
int32.hradio exponential,linear,linear static time
int32_t prev;
int32_t follow;
int64_t diff;
int64_t rate;
rate = ___SMMUL(param_glide << 3, param_glide << 2);
rate = rate << 8;
if (inlet_glideOFF == 0) {
if (param_mode == 0) {
diff = inlet_in - follow;
diff = (diff << 21) / ((1 << 21) + rate);
follow += diff;
outlet_out = follow;
}
if (param_mode == 1) {
if (!(inlet_in == prev)) {
diff = inlet_in - follow;
}
if (diff > 0) {
if (follow > inlet_in) {
diff = 0;
follow = inlet_in;
}
}
if (diff < 0) {
if (follow < inlet_in) {
diff = 0;
follow = inlet_in;
}
}
follow += (diff << 21) / ((1 << 21) + rate);
outlet_out = follow;
prev = inlet_in;
}
if (param_mode == 2) {
if (!(inlet_in == prev)) {
diff = inlet_in - follow;
diff = diff > 0 ? (1 << 27) : -(1 << 27);
}
if (diff > 0) {
if (follow > inlet_in) {
diff = 0;
follow = inlet_in;
}
}
if (diff < 0) {
if (follow < inlet_in) {
diff = 0;
follow = inlet_in;
}
}
follow += (diff << 21) / ((1 << 21) + rate);
outlet_out = follow;
prev = inlet_in;
}
} else {
outlet_out = inlet_in;
}