gateSpreader

This module generates an x-amount of steps within the given max-count (input). Use my "countExt" or "polyCount" module to connect the "max" input/output. After hitting "generate" it will generate new gates one by one, each time checking which distance between gates is the longest and then randomly divides this distance into 2 gates. The maximum amount of gates being generated is set by the "gates" selector and their timing can be quantised with the "qnt" selector (powers of 2!). The amount of gates ACTUALLY TO BE PLAYED depends on the "gates" input which is scaled to the "gates" selector (which just sets the maximum amount of gates to be generated in the array). When the "gate" input is 0, no gate will be generated. When "gate" input goes higher, it adds the gates in the order they were created, making smaller and smaller sections by adding gates in the longest "pauzes". Up to the amount of gates set by the "gate" selector.
Author: Remco van der Most
License: BSD
Github: sss/patt/gateSpreader.axo

Inlets

frac32 gates

int32 count

int32 max

bool32 generate

Outlets

bool32 gate

int32 gates

Parameters

int32 gates

int32 qnt

bool32.mom generate

Declaration
//     number & start/length
int16_t data[32][2];
int i;
int j;
bool gen;
int prv;
bool GEN = 1;
int gates;
Control Rate
if ((GEN > 0) && !gen) {
  gen = 1;
  gates = param_gates; //___SMMUL(param_gates<<3,inlet_gates<<2);
  for (i = 0; i < 32; i++) {
    data[i][0] = 0;
    data[i][0] = 0;
  }
  data[0][1] = inlet_max;
  for (i = 0; i < (gates - 1); i++) {
    int16_t max = 0;
    int pos = 0;
    for (j = 0; j < (i + 1); j++) {
      if (data[j][1] > max) {
        max = data[j][1];
        pos = j;
      }
    }
    int16_t tmp = ___SMMUL((int32_t)(data[pos][1] - (1 << param_qnt)) << 2,
                           (int32_t)(GenerateRandomNumber() &
                                     ((1 << 30 - param_qnt) - 1))) +
                      1
                  << param_qnt;
    data[i + 1][1] = data[pos][1] - tmp;
    data[i + 1][0] = data[pos][0] + tmp;
    data[pos][1] = tmp;
  }
} else if (GEN == 0) {
  gen = 0;
}

outlet_gate = 0;

if (!(inlet_count == prv)) {
  for (i = 0; i < ___SMMUL(gates << 3, inlet_gates << 2); i++) {
    if (inlet_count ==
        data[i][0]) //(___SMMUL((int32_t)(data[i][0])<<14,inlet_max<<3)))
    {
      outlet_gate = 1;
    }
  }
}
prv = inlet_count;
outlet_gates = gates;
GEN = param_generate + inlet_generate;

Privacy

© 2024 Zrna Research