bool32.rising trigger
int32 count
int32 max
frac32 filled
bool32 v
frac32.u.map filled
frac32.u.map fit
frac32.u.map start
frac32.u.map step
int32 quant1
int32 quant2
bool32.tgl gate
static const uint32_t LENGTH = 64;
uint8_t val[LENGTH];
int ntrig;
int i;
int used;
int32_t filled;
int32_t total;
{
for (i = 0; i < LENGTH; i++)
val[i] = 0;
}
ntrig = 0;
total = inlet_max;
total = total > 0 ? total : 1;
total = total > LENGTH ? LENGTH : total;
filled =
___SMMUL(total << 3, __USAT(___SMMUL(param_filled + inlet_filled,
((1 << 27) - param_fit << 3) << 2) +
param_fit,
27)
<< 2);
int32_t fit = ___SMMUL(total << 3, param_fit << 2);
int32_t start = ___SMMUL(total << 3, param_start << 2);
int32_t step = ___SMMUL(total << 3, param_step << 2);
if ((inlet_trig > 0) && !ntrig) {
for (i = 0; i < LENGTH; i++) {
val[i] = 0;
}
ntrig = 1;
} else if (inlet_trig < 1) {
ntrig = 0;
}
for (i = 0; i < fit; i++) {
int k = i * step + start;
val[(k - (k / total) * total >> param_quant2) << param_quant2] = 1;
}
used = 0;
for (i = 0; i < LENGTH; i++) {
used += val[i];
}
if (used < filled) {
val[((int32_t)(GenerateRandomNumber() % (total)) >> param_quant1)
<< param_quant1] = 1;
}
if (used > filled) {
val[(int32_t)(GenerateRandomNumber() % (total))] = 0;
}
outlet_v = val[inlet_count] & (inlet_trig || (param_gate));