bool32.rising stop
frac32.positive attack
frac32.positive release
bool32 gate
bool32 state
bool32.pulse retrig
frac32.positive env
int32.positive note
int32.positive velo
objref polymaster
combo retrigger
spinner ascale
spinner rscale
spinner dclick
int32_t val;
uint8_t pren;
uint8_t prev;
uint8_t velon;
uint8_t index;
uint8_t note;
uint8_t velo;
bool gate;
bool stop;
bool trigon;
bool trigoff;
index = parent->polyIndex;
pren = 0;
prev = 0;
val = 0;
outlet_retrig = 0;
trigon = 0;
trigoff = 0;
note = attr_polymaster.Snote[index] - 1;
velo = attr_polymaster.Svelo[index];
if ((note != pren) || (velo != prev) || (stop && velo)) {
if (note != pren)
val = 0;
stop = 0;
pren = note;
prev = velo;
if (prev) {
trigon = 1;
velon = prev;
if (val)
outlet_retrig = 1;
} else
trigoff = 1;
}
if (outlet_retrig && attr_retrigger)
val = 0;
if (trigon && !gate)
gate = 1;
if (trigoff && gate)
gate = 0;
if (inlet_stop && !stop) {
gate = 0;
stop = 1;
attr_polymaster.Svelo[index] = 0;
attr_polymaster.Rhold[index] = 0;
}
if (gate > 0) {
int32_t t;
MTOF(-inlet_attack, t);
val += (inlet_attack) ? t >> attr_ascale : 1 << (27 - attr_dclick);
} else {
int32_t t;
MTOF(-inlet_release, t);
val -= t >> attr_rscale;
}
val = __USAT(val, 27);
if (val)
attr_polymaster.Rrelease[index] = pren + 1;
else
attr_polymaster.Rrelease[index] = 0;
outlet_gate = gate;
outlet_note = pren;
outlet_velo = velon;
outlet_env = val;
outlet_state = bool(val);