structure_seq

Xor pseudorandom structure sequencer
Author: JLS
License: BSD
Github: jls/seq/structure_seq.axo

Inlets

bool32 active

bool32.rising trigger

bool32.rising reset

Outlets

frac32.positive wave

Declaration
int res;
int gate;

int i;
char k;
int x;

char state[256];
Init
gate = 0;
res = 0;

k = 0;
x = 0;

for (i = 0; i < 256; i++)
  state[i] = GenerateRandomNumber() % 16;
Control Rate
if (inlet_active > 0) {

  if ((inlet_trig > 0) && !gate) {

    k = k ^ state[x] ^ state[k];

    state[x] = k;

    if (x == 255)
      x = 0;

    x++;

    gate = 1;

  }

  else if (!(inlet_trig > 0))
    gate = 0;

  outlet_out = k * (1 << 23);

}

else {

  outlet_out = 0;
}

if ((inlet_rst > 0) && !res) {

  k = 0;
  x = 0;
  res = 1;

  for (i = 0; i < 256; i++)
    state[i] = GenerateRandomNumber() % 16;

}

else if (!(inlet_rst > 0))
  res = 0;

Privacy

© 2024 Zrna Research