int32.positive divide
int32.bipolar octave
bool32.rising sync
bool32.rising reset
frac32 att2dec
frac32 length
int32 multiply
int32 D
int32 M
frac32 peak1
frac32.u.map att2dec
frac32.u.map length
int32 multiply
int32 divide
int32 octave
int32 D
int32 M
uint64_t timer;
uint64_t held;
uint64_t hold;
int ttrig;
int rtrig;
int strig;
int utrig;
int64_t phase;
int32_t count;
int64_t divide;
int32_t multiply;
int8_t octave;
uint32_t tomer;
uint32_t tamer;
int32_t peak1;
int32_t val;
int32_t length;
int32_t att2dec;
int32_t temp;
int32_t D = param_D + inlet_D;
int32_t M = param_M + inlet_M;
octave = param_octave + inlet_octave;
multiply = param_multiply + inlet_multiply;
divide = param_divide + inlet_divide;
length = __USAT(param_length + inlet_length, 27);
att2dec = __USAT(param_att2dec + inlet_att2dec, 27);
if ((inlet_reset > 0) && !utrig) {
utrig = 1;
timer = 0;
} else if (!(inlet_reset > 0)) {
utrig = 0;
}
if ((inlet_sync > 0) && !ttrig) {
ttrig = 1;
held = tamer;
tamer = 0;
} else if (!(inlet_sync > 0)) {
ttrig = 0;
}
tamer += 1;
timer += 1;
if (param_octave >= 0) {
temp = (held * D / M >> octave);
timer = (timer - (timer / temp) * temp);
hold = ___SMMUL((held >> octave) << 3, length << 2);
} else {
temp = (held * D / M << -octave);
timer = (timer - (timer / temp) * temp);
hold = ___SMMUL((held << -octave) << 3, param_length << 2);
}
tomer =
(timer * multiply / divide) - ((timer * multiply / divide) / hold) * hold;
tomer = timer >= hold ? hold : tomer;
int32_t attack;
int32_t decay;
attack = ___SMMUL(att2dec << 3, hold << 2);
decay = hold - attack;
peak1 = tomer > attack ? (1 << 27) - ((((tomer - attack) << 10) / decay) << 17)
: (((tomer << 10) / attack) << 17);
peak1 = ___SMMUL(peak1 << 3, peak1 << 2);
val = val + ((peak1 - val) >> 2);
outlet_peak1 = val;