bool32.rising trigger
bool32.rising reset
bool32 generates a new random step-list
bool32 re-orders the step-list
int32 output
bool32.pulse carry pulse
frac32.u.map changesize of the step, note that for small "maxstep" values, this change parameter should be high to get even a little change.
bool32.mom rnd
int32 amount of step-values (entire sequence length is twice this size, as the generator will also create their negative counterparts)
int32 maximum stepsize to be generated
int32 maximum output value
int32 minimum output value
frac32.s.map chance that a step-value gets updated at a randomise trigger
int ntrig;
int rtrig;
int count;
int32_t A[64];
int32_t B[64];
bool DO = 1;
int i;
bool rtrg;
bool gtrg;
int max;
int val;
count = 0;
ntrig = 0;
rtrig = 0;
val = 0;
outlet_c = 0;
bool rnd = param_rnd || DO || inlet_rnd || inlet_sort;
if ((inlet_trig > 0) && !ntrig) {
count += 1;
if (count >= (param_amtX2 << 1)) {
count = 0;
outlet_c = 1;
val = -B[count];
}
ntrig = 1;
val += B[count];
} else if (!(inlet_trig > 0)) {
ntrig = 0;
}
if ((inlet_r > 0) && !rtrig) {
count = 0;
rtrig = 1;
} else if (!(inlet_r > 0)) {
rtrig = 0;
}
int32_t tmp;
if ((rnd > 0) && !rtrg) {
rtrg = 1;
max = param_amtX2 << 1;
if (!(inlet_sort)) {
for (i = 0; i < param_amtX2; i++) {
tmp = GenerateRandomNumber() >> 4;
tmp = tmp - tmp / param_maxstep * param_maxstep;
tmp = tmp < 0 ? tmp + param_maxstep : tmp;
if (((int32_t)GenerateRandomNumber() >> 5) < param_chance) {
A[i << 1] += ___SMMUL(tmp - A[i << 1] << 2, param_change << 3);
A[(i << 1) + 1] += ___SMMUL(-tmp - A[i << 1] << 2, param_change << 3);
}
}
}
int j;
for (i = 0; i < (param_amtX2 << 1); i++) {
tmp = GenerateRandomNumber() >> 4;
tmp = tmp - tmp / max * max;
tmp = tmp < 0 ? tmp + max : tmp;
B[i] = A[tmp];
for (j = tmp; j < ((param_amtX2 << 1) - 1); j++) {
A[j] = A[j + 1];
}
max -= 1;
}
} else if (rnd == 0) {
rtrg = 0;
}
int width = param_maximum - param_minimum;
int TMP = val - val / width * width;
TMP = TMP < 0 ? TMP + width : TMP;
outlet_o = TMP + param_minimum;
if (DO > 0) {
DO = 0;
}