fibonacci

Fibonacci sequencer. Every time trig is activated, the sequencer goes one cycle forward. At every cycle the output is calculated with the formula o=i1+i2, where i2 is the first preceding output, and i1 is the second preceding output. At reset i1=0 , i2=1 unless i1 and i2 are connected.
Author: Sputnki
License: BSD
Github: sptnk/sequencer/fibonacci.axo

Inlets

int32 first number of the serie

int32 second number of the serie

bool32.rising trigger

bool32.rising reset

Outlets

int32 output

Declaration
int ntrig;
int rtrig;
int i1;
int i2;
Init
ntrig = 0;
rtrig = 0;
i1 = 0;
i2 = 1;
Control Rate
if ((inlet_trig > 0) && !ntrig) {
  i2 = i1 + i2;
  i1 = i2 - i1;
  ntrig = 1;
} else if (!(inlet_trig > 0))
  ntrig = 0;

if ((inlet_r > 0) && !rtrig) {
  if ((inlet_i1 + inlet_i2) + (inlet_i1 * inlet_i2)) {
    i1 = inlet_i1;
    i2 = inlet_i2;
  } else {
    i1 = 0;
    i2 = 1;
  }
  rtrig = 1;
} else if (!(inlet_r > 0))
  rtrig = 0;
outlet_o = i2;

Privacy

© 2024 Zrna Research