pattCount

pattern Counter
Author: Remco van der Most
License: BSD
Github: sss/logic/pattCount.axo

Inlets

bool32.rising trigger

bool32.rising reset

bool32 pendulum

int32 start

int32 steps

int32 restart

int32 loop

int32 size

int32 range

Outlets

int32 output

bool32.pulse carry pulse

Parameters

bool32.tgl pendulum

int32 start

int32 steps

int32 loop

int32 restart

int32 size

int32 chgstep

int32 chgsize

int32 range

Declaration
int ntrig;
int rtrig;
int32_t count;
int dir;
int32_t caunt;
int32_t ciunt;
Init
count = 0;
ntrig = 0;
rtrig = 0;
dir = 1;
Control Rate
outlet_c = 0;
if ((inlet_trig > 0) && !ntrig) {
  if (caunt == 0) {
    ciunt += param_restart + inlet_restart;
  }
  if (param_pendulum + inlet_pendulum > 0) {
    if (count >= param_steps + inlet_steps) {
      dir = -1;
      outlet_c = 1;
    }
    if (count <= 0) {
      dir = 1;
      outlet_c = 1;
      count = param_start + inlet_start;
    }
  } else if (count >= param_steps + inlet_steps) {
    dir = 1;
    count =
        param_start + inlet_start > 0 ? count + param_start + inlet_start : 0;
    outlet_c = 1;
  }
  count += 1 * dir;
  int32_t offset = ((count + ciunt) / (param_loop + inlet_loop));
  caunt = count + ciunt -
          ((count + ciunt) / (param_loop + inlet_loop)) *
              (param_loop + inlet_loop) +
          offset * param_chgstep;
  caunt = caunt * (param_size + inlet_size + offset * param_chgsize) -
          ((caunt * (param_size + inlet_size + offset * param_chgsize)) /
           (param_range + inlet_range)) *
              (param_range + inlet_range);
  ntrig = 1;
} else if (!(inlet_trig > 0))
  ntrig = 0;
if ((inlet_r > 0) && !rtrig) {
  count = 0;
  ciunt = 0;
  rtrig = 1;
} else if (!(inlet_r > 0)) {
  rtrig = 0;
}

outlet_o = caunt;

Privacy

© 2024 Zrna Research