GateRndPattern

random gate pattern generator connect "COUNT" to a counter (sss-logic) connect "LENGTH" to the max-count control CHANCE sets the level to which the internal random pattern is compared. If CHANCE is higher, a high gate is generated. REPEAT sets an euclidian division over the entire length. The smaller the value, the smaller the steps->more gates.
Author: Remco van der Most
License: BSD
Github: sss/patt/GateRndPattern.axo

Inlets

bool32.rising rnd

int32 count

int32 length

Outlets

bool32 rand

Parameters

bool32.mom rand

frac32.u.map chance

frac32.u.map repeat

Declaration
int32_t _val[128];
int32_t vol;
int ntrig;
int8_t lng;
int i;
Init
for (i = 0; i < 128; i++)
  _val[i] = (GenerateRandomNumber()) >> 4;
{}
ntrig = 0;
Control Rate
int32_t repeat = ___SMMUL(param_repeat << 3, inlet_length << 2);
int32_t gtrig = inlet_count - ((inlet_count / repeat) * repeat);
gtrig = gtrig == 0 ? (1 << 27) : 0;

lng = inlet_length;
if (((param_rand + inlet_rnd) > 0) && (!(ntrig))) {
  for (i = 0; i < lng; i++)
    _val[i] = (GenerateRandomNumber()) >> 4;
  {}
  ntrig = 1;
} else if (!((param_rand + inlet_rnd) > 0)) {
  ntrig = 0;
}
vol = _val[inlet_count];
outlet_rand = (param_chance + gtrig > (vol >> 1)) ? (1 << 27) : 0;

Privacy

© 2024 Zrna Research