bool32.risingfalling gate
frac32.positive a
frac32.positive d
bool32.rising reset
frac32.positive envelope output
bool32 state
frac32.s.map curveA
frac32.s.map curveD
int32_t val;
val = 0;
int32_t crv1;
int32_t crv2;
crv1 = param_curveA;
crv2 = param_curveD;
int32_t t;
if (inlet_gate == 0) {
MTOF(-((inlet_d - (1 << 26)) << 2) + ___SMMUL(val - (1 << 30), -crv2 << 2),
t);
val = __USAT(val - (t >> 3), 31);
} else {
MTOF(-((inlet_a - (1 << 26)) << 2) + ___SMMUL(val - (1 << 30), -crv1 << 2),
t);
val = val + (t >> 3);
if (val < 0) {
val = 0x7FFFFFFF;
}
}
if (inlet_reset)
val = 0;
outlet_env = val >> 4;
outlet_state = (val > 0);