u4u

A unipolar k rate function defined by 4 segments. It can be used to shape saw LFOs, enveloppes and many other control signals such as pitch (if you need to control a parameter depending on pitch)...
Author: Smashed Transistors
License: LGPL
Github: tiar/kfunc/u4u.axo

Inlets

frac32 in

Outlets

frac32 out

Parameters

frac32.u.mapvsl p0

frac32.u.mapvsl p1

frac32.u.mapvsl p2

frac32.u.mapvsl p3

frac32.u.mapvsl p4

Control Rate
if (inlet_in >= (1 << 27))
  outlet_out = param_p4;
else if (inlet_in <= 0)
  outlet_out = param_p0;
else {
  int32_t i = inlet_in >> (27 - 2);               // i [0 4[
  int32_t a = (inlet_in & ((1 << (27 - 2)) - 1)); // a q25
  if (i < 2) {                                    // [0 2[
    if (i < 1) { // [0 1[             q27         q25   q20           q27
      outlet_out = ___SMMLA(param_p1 - param_p0, a, param_p0 >> 7) << 7;
    } else { // [1 2[
      outlet_out = ___SMMLA(param_p2 - param_p1, a, param_p1 >> 7) << 7;
    }
  } else {       // [2 4[
    if (i < 3) { // [2 3[
      outlet_out = ___SMMLA(param_p3 - param_p2, a, param_p2 >> 7) << 7;
    } else { // [3 4[
      outlet_out = ___SMMLA(param_p4 - param_p3, a, param_p3 >> 7) << 7;
    }
  }
}

Privacy

© 2024 Zrna Research