pseudo factorial

Pseudo factorial sequencer. Every time trig is activated, the sequencer goes one cycle forward. At every cycle the output is calculated with the formula o=i*(i+a+1), where i is the preceding output. At reset i=1 unless i0 is connected.
Author: Sputnki
License: BSD
Github: sptnk/sequencer/pseudo factorial.axo

Inlets

int32 first number of the serie

int32 a coefficient in the formula

bool32.rising trigger

bool32.rising reset

Outlets

int32 output

Declaration
int ntrig;
int rtrig;
int i;
Init
ntrig = 0;
rtrig = 0;
i = 1;
Control Rate
if ((inlet_trig > 0) && !ntrig) {
  i = (i * (i + inlet_a + 1));
  ntrig = 1;
} else if (!(inlet_trig > 0))
  ntrig = 0;

if ((inlet_r > 0) && !rtrig) {
  if (inlet_i0)
    i = inlet_i0;
  else
    i = 1;
  rtrig = 1;
} else if (!(inlet_r > 0))
  rtrig = 0;
outlet_o = i;

Privacy

© 2024 Zrna Research