frac32buffer i
bool32.rising trigger
frac32.bipolar attack time modulation
frac32.bipolar decay time modulation
frac32buffer o
bool32.tgl on
frac32.s.map a
frac32.s.map d
int32_t prev;
int32_t step;
int8_t stage;
int ntrig;
int32_t val;
int32_t Loopval;
ntrig = 0;
val = 0;
// vca
step = (Loopval - prev) >> 4;
int32_t i = prev;
prev = Loopval;
// env
if ((inlet_t > 0) && !ntrig) {
ntrig = 1;
stage = 1;
} else if (!(inlet_t > 0)) {
ntrig = 0;
}
if (stage == 0) {
val = ___SMMUL(val, param_d) << 1;
} else {
int32_t t;
MTOF(-param_a, t);
val = val + (t >> 3);
if (val < 0) {
val = 0x7FFFFFFF;
stage = 0;
}
}
Loopval = val >> 4;
// Env off
outlet_o = inlet_i;
// Env on
if (param_on) {
outlet_o = ___SMMUL(inlet_i, i) << 5;
i += step;
}