clockswing2

adds swing to a trigger signal First gate/trigger is let through as a short trigger Second gate/trigger resets the internal counter and only generates a short trigger if the internal counter passes the swing value. Internal counter is at krate. Most swing values will be between 0 (no swing) and 200. If the swing value is so high that the counter will be reset before it has generated a trigger, it won't generate a trigger. So it's useful to add a reset signal (once every 64 steps? or more?) to both the swing module and the sequencer that you're providing the swing to.
Author: Remco van der Most
License: BSD
Github: sss/seq/clockswing2.axo

Inlets

bool32.rising uses a gate/trigger signal (eg for sequencers)

bool32 resets internal 1st/2nd trigger counter

int32 sets swing position (the higher the value, the later the 2nd trigger will be generated)

Outlets

bool32.pulse trigOut

Parameters

int32 swing

int32 repeat

Declaration
int array1[64];
int16_t cnt;
int cot;
int ttrig;
int dtrig;
int swingOn;
int gtrig;
int16_t swingsize;
Init
cnt = 999;
Control Rate
int32_t repeat = param_repeat;
outlet_trigOut = 0;
cnt += 1;
cnt = cnt > 999 ? 999 : cnt;
if ((inlet_trigIn > 0) && (!(ttrig))) {
  swingsize = inlet_swing + param_swing;
  ttrig = 1;
  cot += 1;
  cot = cot - (cot / repeat) * repeat;
  if (cot >= (repeat >> 1)) {
    cnt = 0;
  } else if (cot < (repeat >> 1)) {
    outlet_trigOut = 1;
  }
} else if (!(inlet_trigIn > 0)) {
  ttrig = 0;
}

swingOn = (cnt > (swingsize));
if (swingOn && (!(dtrig))) {
  dtrig = 1;
  gtrig = 1;
} else {
  gtrig = 0;
  if (!(swingOn > 0))
    dtrig = 0;
}
outlet_trigOut += gtrig;

Privacy

© 2024 Zrna Research