bool32.rising trigger
bool32.rising reset
bool32 rnd
bool32 gate
int32 length
int32 max
int32 min
frac32.u.map chance
int ntrig;
int rtrig, DO = 1;
int count;
int cnt[64], CNT;
int step, rnd;
count = 0;
ntrig = 0;
rtrig = 0;
step = 1;
int RND = inlet_rnd || DO;
if (RND && !rnd) {
DO = 0;
rnd = 1;
for (int i = 0; i < 8; i++) {
cnt[i] = (int32_t)(GenerateRandomNumber() >> 1);
}
} else if (rnd && !RND) {
rnd = 0;
}
if ((inlet_trig > 0) && !ntrig) {
if ((count % step) < 1) {
if ((GenerateRandomNumber() >> 5) < param_chance) {
int dif = param_max - param_min;
int dir = dif >= 0 ? 1 : -1;
dif = (dif > 0 ? dif : -dif) + 1;
step = (cnt[CNT] % (dif)) * dir + param_min;
CNT = (CNT + 1) & 63;
}
}
count += 1;
count = count >= param_length ? 0 : count;
ntrig = 1;
} else if (!(inlet_trig > 0)) {
ntrig = 0;
}
if ((inlet_r > 0) && !rtrig) {
count = 0;
CNT = 0;
rtrig = 1;
} else if (!(inlet_r > 0))
rtrig = 0;
if (step & 1) {
if (step < 5) {
// outlet_gate=(count%step)>(step>>1);
outlet_gate = ((count % step) < (step - 1 + (1 >> 1)));
} else {
outlet_gate = !((count % step) > (step >> 1));
}
} else {
if (step < 5) {
outlet_gate = ((count % step) < (step - 1 + (1 >> 1)));
} else {
outlet_gate = ((count % step) >= (step >> 1));
}
}