autoknob

knob with an inbuild (randomisable) automator and pattern selector for live use. Doesn't save it's patterns! Pattern size and amount of patterns can be set using the attributes. you can randomise just the selected pattern or all patterns at the same time. Use the max/min knobs to set your desired output scaling
Author: Remco van der Most
License: BSD
Github: sss/patt/autoKnob.axo

Inlets

int32 count

int32 pattern

bool32.rising RndAll

bool32.rising RndPt

Outlets

frac32.positive output

Parameters

bool32.mom RndPt

bool32.mom RndAll

int32 max

int32 min

frac32.u.map value

Attributes

spinner size

spinner patt

Declaration
static const int32_t LENGTH = (attr_size * attr_patt);
int32_t LENGTHMASK = attr_size;
int32_t *array;
int32_t prev;
int32_t prav;
int atrig;
int rtrig;
int i;
int32_t out;
Init
static int32_t _array[LENGTH] __attribute__((section(".sdram")));
array = &_array[0];
Control Rate
int32_t pattern =
    (inlet_pattern - (inlet_pattern / attr_patt) * attr_patt) * attr_size;
int32_t count =
    (inlet_count - (inlet_count / LENGTHMASK) * LENGTHMASK) + pattern;

if (!(count == prav)) {
  if (!(param_value == array[prav])) {
    array[count] = __USAT(param_value, 27);
  } else {
    PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_value],
                       array[count], 0xFFFD);
  }
  out = array[count];
}
prav = count;
if (!(param_value == array[prav])) {
  array[count] = __USAT(param_value, 27);
}
outlet_out = out;

if ((param_RndAll || inlet_RndAll) && !atrig) {
  atrig = 1;
  int32_t diff = (param_max - param_min) << 21;
  for (i = 0; i < LENGTH; i++)
    array[i] = ___SMMUL(((uint32_t)(GenerateRandomNumber() >> 1)), diff << 1) +
               (param_min << 21);
} else if ((param_RndAll || inlet_RndAll) == 0) {
  atrig = 0;
}

if ((param_RndPt || inlet_RndPt) && !rtrig) {
  rtrig = 1;
  int32_t diff = (param_max - param_min) << 21;
  for (i = 0; i < LENGTHMASK; i++)
    array[i + pattern] =
        ___SMMUL(((uint32_t)(GenerateRandomNumber() >> 1)), diff << 1) +
        (param_min << 21);
} else if ((param_RndPt || inlet_RndPt) == 0) {
  rtrig = 0;
}

Privacy

© 2024 Zrna Research