qSmRnd

With each trigger, the algorithm will randomly choose to go up or down a set value. The value depends on the "div" input, dividing the 0 to 64 range into an "x" amount of steps. The rate controls the change-rate at each new value.
Author: Remco van der most
License: GPL
Github: sss/rand/qSmRnd.axo

Inlets

int32 div

frac32 rate

bool32 trig

Outlets

frac32 out

Parameters

frac32.s.map.lfopitch rate

Declaration
int32_t pos;
int gtrig;
int32_t val;
int32_t out;
Control Rate
int32_t step = (1 << 27) / inlet_div;
int dir;
if ((inlet_trig > 0) && !gtrig) {
  gtrig = 1;
  dir = GenerateRandomNumber() & 1;
  if (dir > 0) {
    pos += step;
  } else {
    pos -= step;
  }
  pos = pos < 0 ? -pos : pos;
  pos = pos > (1 << 27) ? (1 << 28) - pos : pos;
  pos = pos / step * step;

} else if (inlet_trig == 0) {
  gtrig = 0;
}
int32_t F;
MTOF(param_rate + inlet_rate, F)
val = ___SMMLA(((pos - out) - val) << 1, F >> 1, val);
out = ___SMMLA(val << 1, F >> 2, out);
outlet_out = out;

Privacy

© 2024 Zrna Research