curveQnt

Quantized curvings, to be used with the morphing table oscillators Quantizes the 0-64 range into equal parts and creates a curve between the quantification points. This is controlled by the "div" input. Curve is created by the exp and mod controls. negative exp=exponential positive exp=inverse exponential negative mod= inverse s-curve positive mod= s-curve. mod is actually a modulation of the exp input by the signal itself, fading from exponential to inverse exponential (or the other way around) and added to the exp-control. SO: When you want an (inverse) exponential curve, only use the exp-control When you want a S-curve, first dial in the mod-control and use the exp-control to offset the center of the s-curve. The exp and mod controls are being updated only when the signal goes over to a new part of the quantification.
Author: Remco van der Most
License: BSD
Github: sss/math/curveQnt.axo

Inlets

frac32 in

frac32 exp

frac32 mod

int32 div

Outlets

frac32 out

Parameters

frac32.s.map exp

frac32.s.map mod

int32 stack

Declaration
int i;
int32_t expo[32];
int dir;
int32_t pEXP;
int32_t sEXP;
int32_t pMOD;
int32_t sMOD;
int32_t sOFS;
int32_t pOFS;
int32_t prev;
int DO;
int32_t EXP;
int32_t MOD;
int32_t OFS;
Init
DO = 1;
Control Rate
int32_t step = (inlet_in >> 4) * inlet_div >> 23;
int32_t mix = (inlet_in - ((step << 23) / inlet_div << 4)) * inlet_div;

if ((DO > 0) || (!(prev == step))) {
  DO = 0;
  EXP = __SSAT(param_exp + inlet_exp, 28);
  MOD = __SSAT(param_mod + inlet_mod, 28);
}

int32_t IN = mix;
int32_t inexpo = __SSAT(EXP + ___SMMUL((IN - (1 << 26)) << 3, MOD << 3), 28);
dir = inexpo > 0 ? 1 : -1;
inexpo = inexpo > 0 ? inexpo : -inexpo;
int32_t inv = (1 << 27) - inexpo;
int32_t out;
int dar;
dar = inlet_in > 0 ? 1 : -1;
int32_t pos = IN;
pos = pos > 0 ? pos : -pos;
if (dir > 0) {
  expo[0] = ___SMMUL(pos << 3, (inv + ___SMMUL(inexpo << 3, pos << 2)) << 2);
}
if (dir < 0) {
  expo[0] =
      ___SMMUL(((1 << 27) - pos) << 3,
               (inv + ___SMMUL(inexpo << 3, ((1 << 27) - pos) << 2)) << 2);
}
for (i = 1; i <= param_stack; i++)
  expo[i] = ___SMMUL(expo[i - 1] << 3,
                     (inv + ___SMMUL(inexpo << 3, expo[i - 1] << 2)) << 2);
if (dir > 0) {
  out = (expo[param_stack] * dar);
}
if (dir < 0) {
  out = (((1 << 27) - expo[param_stack]) * dar);
}

outlet_out = ((step << 23) / inlet_div << 4) + out / inlet_div;

prev = step;

Privacy

© 2024 Zrna Research