int32 selects out of 16 randomised presets
bool32 randomises internal random sequence
frac32buffer outputs coëfficients for FIR filter
bool32.mom randomises internal pattern
frac32.u.map chance of new random value when value is within the "diff" range of the goal value
frac32.u.map random rate width
frac32.u.map mixes between sequential and morphing random values
frac32.s.map base random morph rate
frac32.s.map smooths the sequential random values
int32_t val[16];
int32_t Val[16];
int32_t seq[16][16];
int32_t rnd[16];
int32_t rate[16];
int i;
int32_t prv;
int32_t v30 = 1 << 30;
bool rd;
int32_t lp[BUFSIZE];
for (i = 0; i < 16; i++) {
Val[i] = 0;
}
Val[0] = 1 << 30;
for (i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
seq[i][j] = (int32_t)(GenerateRandomNumber()) >> 3;
}
}
int sel = inlet_seq & 15;
bool RND = param_rnd || inlet_rnd;
if (RND && !rd) {
rd = 1;
for (i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
seq[i][j] = (int32_t)(GenerateRandomNumber()) >> 3;
}
}
} else if (!RND) {
rd = 0;
}
int32_t update = param_update;
;
update = ___SMMUL(update << 3, update << 2);
update = ___SMMUL(update << 3, update << 2);
int32_t smth;
MTOF(param_smooth, smth)
smth = smth >> 2;
for (i = 0; i < 16; i++) {
int diff = rnd[i] - val[i];
diff = diff > 0 ? diff : -diff;
if (((int32_t)(GenerateRandomNumber() >> 5) < update) && (diff < (1 << 19))) {
rnd[i] = (int32_t)(GenerateRandomNumber()) >> 3;
MTOF(param_rate +
___SMMUL((int32_t)GenerateRandomNumber(), param_width << 1),
rate[i])
rate[i] = rate[i] >> 2;
}
val[i] += ___SMMUL(rnd[i] - val[i], rate[i]);
int32_t a = seq[sel][i];
lp[i] += ___SMMUL(smth, a - lp[i]);
a = lp[i];
int32_t b = val[i];
a += ___SMMUL(b - a, param_change << 4) << 1;
outlet_coefs[i] = a << 1;
}