gateFiller

Euclidian gate generator and random "trigger-filler". Randomly fills up the array with gates until the desired amount of gates is reached. When the "filled" control is dailed up, it randomly adds more and more gates to the remaining positions. When the "filled" control is dialed down, it randomly removes more and more gates from the array. Controlling the "filled" externally wil slowely transform the randomised pattern. Next to the random gates, there's also an euclidian pattern generator. -start sets the start-count-offset (when zero, first gate on will always be on the first count). -step sets the stepsize between gates (when set to 5, each next fifth position in the array will be high, wraps when max-count is reached) -fit sets the amount of steps that will be set high. NOTE! Depending on the stepsize and quantification this could or could not fill up the entire array: when max is set to 32 and stepsize is 4, it will repeat putting the same positions to a gate high over and over, skipping all other positions. -Quantification controls set the division that the notes may be filling (eight, quarter, half, whole beat) The higher the setting, the larger the quantification step (power of 2).
Author: Remco van der Most
License: BSD
Github: sss/patt/gateFiller.axo

Inlets

bool32.rising trigger

int32 count

int32 max

frac32 filled

Outlets

bool32 v

Parameters

frac32.u.map filled

frac32.u.map fit

frac32.u.map start

frac32.u.map step

int32 quant1

int32 quant2

bool32.tgl gate

Declaration
static const uint32_t LENGTH = 64;
uint8_t val[LENGTH];
int ntrig;
int i;
int used;
int32_t filled;
int32_t total;
Init
{
  for (i = 0; i < LENGTH; i++)
    val[i] = 0;
}

ntrig = 0;
Control Rate
total = inlet_max;
total = total > 0 ? total : 1;
total = total > LENGTH ? LENGTH : total;
filled =
    ___SMMUL(total << 3, __USAT(___SMMUL(param_filled + inlet_filled,
                                         ((1 << 27) - param_fit << 3) << 2) +
                                    param_fit,
                                27)
                             << 2);
int32_t fit = ___SMMUL(total << 3, param_fit << 2);
int32_t start = ___SMMUL(total << 3, param_start << 2);
int32_t step = ___SMMUL(total << 3, param_step << 2);
if ((inlet_trig > 0) && !ntrig) {
  for (i = 0; i < LENGTH; i++) {
    val[i] = 0;
  }
  ntrig = 1;
} else if (inlet_trig < 1) {
  ntrig = 0;
}

for (i = 0; i < fit; i++) {
  int k = i * step + start;
  val[(k - (k / total) * total >> param_quant2) << param_quant2] = 1;
}

used = 0;
for (i = 0; i < LENGTH; i++) {
  used += val[i];
}
if (used < filled) {
  val[((int32_t)(GenerateRandomNumber() % (total)) >> param_quant1)
      << param_quant1] = 1;
}
if (used > filled) {
  val[(int32_t)(GenerateRandomNumber() % (total))] = 0;
}

outlet_v = val[inlet_count] & (inlet_trig || (param_gate));

Privacy

© 2024 Zrna Research