rndPattF

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/rndPattF.axo

Inlets

bool32.rising when triggered steps in the array get randomised controlled by chance/change settings

int32 input for the counter (logic->counter)

int32 maximum count (eg. use my counter modules as these have in/outs for the length set)

int32 external randomise chance input

frac32 external change size input

frac32 external control for max output value

frac32 external control for min output value

Outlets

frac32 v

bool32.pulse rnd

Parameters

frac32.u.map sets a repeat length within zero and the "length" input/max array size. 32 would be half way the length. 22 would select 1/3 of the length input/max array size.

frac32.u.map change-size from current value when a step is randomised

frac32.u.map Sets a chance of a random offset added to the pattern. This offset is not put into the memory and occurs only once.

frac32.u.map Sets the size of the random offset away from the repeating pattern.

frac32.u.map Sets the chance that the output freezes for a random amount of counts

frac32.u.map Sets the maximum amount of counts that the output can be frozen

frac32.u.map move the CV knob to auto-record the values of the knob to the pattern

int32 chance that steps get randomised when a trigger is received at the input

bool32.mom press to randomise pattern

frac32.s.map maximum output value

frac32.s.map minimum output value

Attributes

spinner maxSteps

Declaration
int get[attr_maxSteps];
uint32_t val[attr_maxSteps];
int ntrig;
int count;
int32_t length;
int i;
int on;
int prev;
int32_t Gen;
uint32_t pv;
int upd;
uint32_t Tmp;
Init
on = 1;
ntrig = 0;
Control Rate
int chance = param_chance + inlet_chance;
int32_t change = param_change + inlet_change;
chance = chance < 0 ? 0 : chance;
chance = chance > 100 ? 100 : chance;
int trig = inlet_rnd + param_rnd;
int32_t width = param_max + inlet_max - param_min - inlet_min;

if (inlet_length > 0) {
  length = ___SMMUL(param_repeat << 3, inlet_length + 1 << 2);
} else
  length = param_repeat >> 21;
int TRIG = 0;
if ((trig > 0) && !ntrig) {
  TRIG = 1;
  int32_t size = change << 3;
  for (i = 0; i < attr_maxSteps; i++) {
    get[i] = (int32_t)(GenerateRandomNumber() % (100));
    if (get[i] <= chance) {
      val[i] +=
          (___SMMUL((uint32_t)(GenerateRandomNumber() & ((1 << 31) - 1)), size)
           << 2) -
          size;
      val[i] = val[i] & ((1 << 31) - 1);
      val[i] = val[i] > (1 << 30) ? (1 << 31) - val[i] : val[i];
    }
  }
  ntrig = 1;
} else if (!(trig > 0))
  ntrig = 0;
count = inlet_count - (inlet_count / length) * length;

if (!(count == pv)) {
  upd = __USAT(upd - 1, 28);
  Gen = ((uint32_t)(GenerateRandomNumber()) >> 5) < param_nonMemRnd ? 1 : 0;
  if (Gen == 1) {
    Gen = ___SMMUL(param_size, (int32_t)GenerateRandomNumber()) << 5;
  }
  if (upd == 0) {
    upd = ((uint32_t)(GenerateRandomNumber()) >> 5) < param_freeze
              ? param_maxFreeze >> 23
              : 0;
  }
}
if (!(param_CV == prev)) {
  val[count] = param_CV << 3;
}
if (upd == 0) {
  Tmp = val[count] + Gen;
  Tmp = Tmp & ((1 << 30) - 1);
}

outlet_v = (___SMMUL(Tmp >> 1, width) << 3) + param_min + inlet_min;
if (on > 0) {
  for (i = 0; i < attr_maxSteps; i++) {
    val[i] = (uint32_t)(GenerateRandomNumber() >> 2);
  }
}

on = 0;
outlet_rnd = TRIG;
prev = param_CV;

pv = count;

Privacy

© 2024 Zrna Research