fibonacci a*b

A variation on the 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=1 , i2=2 unless i1 and i2 are connected.
Author: Sputnki
License: BSD
Github: sptnk/sequencer/fibonacci astarb.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 = 1;
i2 = 2;
Control Rate
if ((inlet_trig > 0) && !ntrig) {
  int temp = i2;
  i2 = i1 * i2;
  i1 = temp;
  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 = 1;
    i2 = 2;
  }
  rtrig = 1;
} else if (!(inlet_r > 0))
  rtrig = 0;
outlet_o = i2;

Privacy

© 2024 Zrna Research