gateburst

Gate burst generator min/max controls set the minimum and maximum trigger length (after how many input-triggers it retriggers). Minimum is 2 (up and down cost 2 triggers). So connect this to a clock that's running twice, tripple or four times the base tempo.
Author: Remco van der Most
License: BSD
Github: sss/patt/gateburst.axo

Inlets

bool32.rising trigger

bool32.rising reset

bool32 rnd

Outlets

bool32 gate

Parameters

int32 length

int32 max

int32 min

frac32.u.map chance

Declaration
int ntrig;
int rtrig, DO = 1;
int count;
int cnt[64], CNT;
int step, rnd;
Init
count = 0;
ntrig = 0;
rtrig = 0;
step = 1;
Control Rate
int RND = inlet_rnd || DO;
if (RND && !rnd) {
  DO = 0;
  rnd = 1;
  for (int i = 0; i < 8; i++) {
    cnt[i] = (int32_t)(GenerateRandomNumber() >> 1);
  }
} else if (rnd && !RND) {
  rnd = 0;
}

if ((inlet_trig > 0) && !ntrig) {
  if ((count % step) < 1) {
    if ((GenerateRandomNumber() >> 5) < param_chance) {
      int dif = param_max - param_min;
      int dir = dif >= 0 ? 1 : -1;
      dif = (dif > 0 ? dif : -dif) + 1;
      step = (cnt[CNT] % (dif)) * dir + param_min;
      CNT = (CNT + 1) & 63;
    }
  }
  count += 1;
  count = count >= param_length ? 0 : count;
  ntrig = 1;
} else if (!(inlet_trig > 0)) {
  ntrig = 0;
}

if ((inlet_r > 0) && !rtrig) {
  count = 0;
  CNT = 0;
  rtrig = 1;
} else if (!(inlet_r > 0))
  rtrig = 0;

if (step & 1) {
  if (step < 5) {
    // outlet_gate=(count%step)>(step>>1);
    outlet_gate = ((count % step) < (step - 1 + (1 >> 1)));
  } else {
    outlet_gate = !((count % step) > (step >> 1));
  }
} else {
  if (step < 5) {
    outlet_gate = ((count % step) < (step - 1 + (1 >> 1)));
  } else {
    outlet_gate = ((count % step) >= (step >> 1));
  }
}

Privacy

© 2024 Zrna Research