int32 gate
frac32.positive envelope output
frac32.u.map s
frac32.s.map.klineartime.exp2 a
frac32.s.map.kdecaytime.exp d
frac32.s.map.kdecaytime.exp r
int8_t stage;
int ntrig;
int rtrig;
int32_t val;
int mode;
int32_t R;
int32_t S;
int32_t gate;
int32_t v27 = 1 << 27;
stage = 0;
ntrig = 0;
val = 0;
if ((inlet_gate > 0) && !rtrig) {
mode = inlet_gate;
rtrig = 1;
gate = v27;
rtrig = 1;
}
if (mode < 3) {
if (!(inlet_gate > 0)) {
gate = 0;
rtrig = 0;
}
}
if (mode == 3) {
if (stage == 2) {
gate = __USAT(gate - (v27 - param_s), 27);
}
}
if (inlet_gate == 0) {
rtrig = 0;
gate = 0;
}
if ((gate > 0) && !ntrig) {
if (mode == 1) {
R = param_d;
S = 0;
}
if (mode == 2) {
R = param_r;
S = param_s;
}
if (mode == 3) {
R = param_r;
S = v27;
}
stage = 1;
ntrig = 1;
}
if (!(gate > 0) && ntrig) {
stage = 0;
ntrig = 0;
}
if (stage == 0) {
val = ___SMMUL(val, R) << 1;
} else if (stage == 1) {
val = val + param_a;
if (val < 0) {
val = 0x7FFFFFFF;
stage = 2;
}
} else if (stage == 2) {
val = (S << 4) + (___SMMUL(val - (S << 4), param_d) << 1);
}
outlet_env = val >> 4;