b2u

A bipolar input, unipolar output k rate function defined by 2 segments.
Author: Smashed Transistors
License: LGPL
Github: tiar/kfunc/b2u.axo

Inlets

frac32.bipolar in

Outlets

frac32 out

Parameters

frac32.u.map p0

frac32.u.map p1

frac32.u.map p2

Control Rate
int32_t in = (inlet_in + (1 << 27)) >> 1;
if (in >= (1 << 27))
  outlet_out = param_p2;
else if (in <= 0)
  outlet_out = param_p0;
else {
  int32_t i = in >> (27 - 1);               // i [0 2[
  int32_t a = (in & ((1 << (27 - 1)) - 1)); // a q26
  if (i < 1) { // [0 1[             q27         q26   q21           q27
    outlet_out = ___SMMLA(param_p1 - param_p0, a, param_p0 >> 6) << 6;
  } else { // [1 2[
    outlet_out = ___SMMLA(param_p2 - param_p1, a, param_p1 >> 6) << 6;
  }
}

Privacy

© 2024 Zrna Research