u8b

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

Inlets

frac32 in

Outlets

frac32 out

Parameters

frac32.s.mapvsl p0

frac32.s.mapvsl p1

frac32.s.mapvsl p2

frac32.s.mapvsl p3

frac32.s.mapvsl p4

frac32.s.mapvsl p5

frac32.s.mapvsl p6

frac32.s.mapvsl p7

frac32.s.mapvsl p8

Control Rate
if (inlet_in >= (1 << 27))
  outlet_out = param_p8;
else if (inlet_in <= 0)
  outlet_out = param_p0;
else {
  int32_t i = inlet_in >> (27 - 3);               // i [0 8[
  int32_t a = (inlet_in & ((1 << (27 - 3)) - 1)); // a q24
  if (i < 4) {                                    // [0 4[
    if (i < 2) {                                  // [0 2[
      if (i < 1) { // [0 1[             q27         q24   q19           q27
        outlet_out = ___SMMLA(param_p1 - param_p0, a, param_p0 >> 8) << 8;
      } else { // [1 2[
        outlet_out = ___SMMLA(param_p2 - param_p1, a, param_p1 >> 8) << 8;
      }
    } else {       // [2 4[
      if (i < 3) { // [2 3[
        outlet_out = ___SMMLA(param_p3 - param_p2, a, param_p2 >> 8) << 8;
      } else { // [3 4[
        outlet_out = ___SMMLA(param_p4 - param_p3, a, param_p3 >> 8) << 8;
      }
    }
  } else {         // [4 8[
    if (i < 6) {   // [4 6[
      if (i < 5) { // [4 5[
        outlet_out = ___SMMLA(param_p5 - param_p4, a, param_p4 >> 8) << 8;
      } else { // [5 6[
        outlet_out = ___SMMLA(param_p6 - param_p5, a, param_p5 >> 8) << 8;
      }
    } else {       // [6 8[
      if (i < 7) { // [6 7[
        outlet_out = ___SMMLA(param_p7 - param_p6, a, param_p6 >> 8) << 8;
      } else { // [7 8[
        outlet_out = ___SMMLA(param_p8 - param_p7, a, param_p7 >> 8) << 8;
      }
    }
  }
}

Privacy

© 2024 Zrna Research