rndPatt

random generated pattern each time a trigger is received, positions of the pattern will be randomised or not, depending on the change parameter (in percentage, so 100 is randomising the whole pattern when triggered). Connect a control to the "length" input to set the total length of the incoming count (eg use my counter, where the max-control is controlled externally and use that max-control to control both modules' length). With the length-parameter you can set a division of the total length, repeating only a part of the random values. eg. set max to 8 and the length-knob to about 21.00 and you'll get a 1,2,3,1,2,3,1,2 repetition. The chance-parameter sets the chance that any position in the pattern will be randomised when a random-trigger is received. The pattern will be newly randomised each time you start up your axoloti.
Author: Remco van der Most
License: BSD
Github: sss/patt/rndPatt.axo

Inlets

bool32.rising trigger

int32 count

int32 length

int32 maxi

int32 cha

int32.bipolar off

Outlets

int32.positive v

bool32.pulse rnd

Parameters

int32 max

int32 offset

int32 chance

frac32.u.map length

bool32.mom rnd

Declaration
static const uint32_t LENGTH = 64;
uint8_t *get;
int32_t *val;

int ntrig;
int count;
int32_t length;
int i;
int on;
Init
static uint8_t _get[LENGTH] __attribute__((section(".sdram")));
get = &_get[0];
static int32_t _val[LENGTH] __attribute__((section(".sdram")));
val = &_val[0];

on = 1;
ntrig = 0;
Control Rate
int trig = inlet_rnd + param_rnd;
if (inlet_length > 0) {
  length = ___SMMUL(param_length << 3, inlet_length << 2);
} else
  length = param_length >> 21;
int TRIG = 0;
if ((trig > 0) && !ntrig) {
  TRIG = 1;
  for (i = 0; i < 64; i++) {
    get[i] = (int32_t)(GenerateRandomNumber() % (100));
    if (get[i] <= param_chance + inlet_cha) {
      val[i] = (int32_t)(GenerateRandomNumber() % (param_max + inlet_maxi));
    }
  }
  ntrig = 1;
} else if (!(trig > 0))
  ntrig = 0;
count = inlet_count - (inlet_count / length) * length;
outlet_v = param_offset + inlet_off + val[count];
if (on > 0) {
  for (i = 0; i < 64; i++) {
    val[i] = (int32_t)(GenerateRandomNumber() % (param_max + inlet_maxi));
  }
}

on = 0;
outlet_rnd = TRIG;

Privacy

© 2024 Zrna Research