bool32.risingfalling gate
frac32.positive env
frac32.s.map.klineartime.exp delay
frac32.s.map.kdecaytime.exp a
frac32.s.map.kdecaytime.exp d
int32_t val;
int32_t delay;
int32_t ntrig;
val = 0;
delay = 0;
ntrig = 0;
if (inlet_gate > 0) {
if (ntrig == 0) {
ntrig = 1;
} else {
if (delay < (1 << 27)) {
int32_t t;
MTOF(-param_delay, t);
delay += t >> 6;
val = ___SMMUL(val, param_d) << 1;
} else {
val = (1 << 27) - (___SMMUL((1 << 27) - val, param_a) << 1);
}
}
} else {
ntrig = 0;
val = ___SMMUL(val, param_d) << 1;
delay = 0;
}
outlet_env = val;