lfsrseq

linear feedback shift register cyclic pattern, cycled with trigger input.
Author: Johannes Taelman
License: BSD
Github: seq/lfsrseq.axo

Inlets

bool32.rising trigger

bool32.rising reset

bool32.rising load trigger

int32 load value

Outlets

bool32 lfs pattern

Attributes

combo polynomial

Declaration
uint32_t state;
int ntrig;
int rtrig;
int ltrig;
Init
state = 1;
ntrig = 0;
rtrig = 0;
ltrig = 0;
Control Rate
if ((inlet_trig > 0) && !ntrig) {
  ntrig = 1;
  if (state & 1) {
    state = (state >> 1) ^ attr_polynomial;
  } else {
    state = (state >> 1);
  }
} else if (!(inlet_trig > 0))
  ntrig = 0;
if ((inlet_r > 0) && !rtrig) {
  state = 1;
  rtrig = 1;
} else if (!(inlet_r > 0))
  rtrig = 0;
if ((inlet_load > 0) && !ltrig) {
  state = inlet_lval;
  ltrig = 1;
} else if (!(inlet_load > 0))
  ltrig = 0;
outlet_out = state & 1;

Privacy

© 2024 Zrna Research