bool32.rising trigger
frac32.positive envelope output
frac32.s.map.klineartime.exp a1
frac32.s.map.klineartime.exp a2
frac32.s.map.kdecaytime.exp d1
frac32.s.map.kdecaytime.exp d2
int8_t stage;
int ntrig;
int32_t val;
int32_t val2;
int32_t attack;
int32_t decay;
ntrig = 0;
val = 0;
if ((inlet_trig > 0) && !ntrig) {
ntrig = 1;
stage = 1;
} else if (!(inlet_trig > 0)) {
ntrig = 0;
}
if (stage == 0) {
val = ___SMMUL(val, param_d1 + decay + (1 << 17)) << 1;
} else {
int32_t t;
MTOF(-attack, t);
val = val + (t >> 3);
if (val < 0) {
val = 0x7FFFFFFF;
stage = 0;
}
}
outlet_env = val >> 4;
val2 = (1 << 27) - (val >> 4);
attack = ___SMMUL(val2 << 3, param_a1 << 2) + ___SMMUL(val >> 1, param_a2 << 2);
decay = ___SMMUL(val2 << 3, (param_d2 - param_d1) << 2);