goalStepper

pattern generator that steps from a former value to a new value in a set amount of steps. INPUTS: "next" sets the next goal that the pattern will go to. at each trigger at the "trig" input, it will advance 1 step. "steps" sets the pattern length, after which the goal (new value) is reached. "stepsize" sets the count-size for the pattern, skipping intermediate steps and repeating steps, but making sure the last step will always be the goal. OUTPUTS: "out" outputs the pattern-value "count" outputs the count-position->maximum is set by the "steps" input "next" outputs a trigger when the maximum count is reached. By making a loop between this module and a counter and LFO (qtsLFO4), interesting patterns can be made: -connect "steps" output to the multiply input on the qtsLFO4, this way each stage takes the same time, but with a different measure (7/8, 9/8 15/8 etc etc) Don't forget to set the multiply parameter to 0, as it would otherwise offset the count-rate from host position! -connect the LFO output to the "trig" input and set the waveform to square (switch-position to 5) -connect the "next" output to a counter -connect counter output to 3 "sel/sel dial8" modules. -connect one sel/dial8 module to the "next" input, feeding the "goal-values" -connect one to the "steps" input, setting how many steps it will take to reach the next value -connect the last one to the "stepsize" input, enabling different patterns for each stage.
Author: Remco van der Most
License: BSD
Github: sss/patt/goalStepper.axo

Inlets

frac32 next

frac32 stepsize

bool32 trig

int32 steps

Outlets

bool32 next

frac32 out

int32 count

int32 steps

Declaration
int32_t count;
int32_t former;
int32_t next;
int ctrig;
int ttrig;
int32_t tcount;
int32_t steps;
int32_t Stepsize;
Init
count = 0;
Control Rate
if ((count == 0) && !ctrig) {
  steps = inlet_steps;
  ctrig = 1;
  former = next;
  next = inlet_next;
  outlet_next = 1;
} else if (!(count == 0)) {
  ctrig = 0;
  outlet_next = 0;
}
if ((inlet_trig > 0) && !ttrig) {
  ttrig = 1;
  count += 1;
  count = count - (count / steps) * steps;
  Stepsize = inlet_stepsize;
} else if (inlet_trig == 0) {
  ttrig = 0;
}

tcount = count * (___SMMUL(Stepsize << 3, steps - 1 << 2) + 1);
tcount = tcount - (tcount / steps) * steps;
outlet_out = former + ((next - former)) * tcount / steps;
outlet_count = count;
outlet_steps = steps;

Privacy

© 2024 Zrna Research