knee 2

3-piece polygonal curve, in the shape of a double knee
Author: Sputnki
License: BSD
Github: sptnk/math/knee 2.axo

Inlets

frac32 in

frac32 x position at which the first knee happens. You should have x1<x2

frac32 constant output before first knee

frac32 x position at which the second knee happens. You should have x1<x2

frac32 costant output after second knee

Outlets

frac32 out

Parameters

frac32.s.map x position at which the first knee happens. You should have x1<x2

frac32.s.map constant output before first knee

frac32.s.map x position at which the second knee happens. You should have x1<x2

frac32.s.map constant output after second knee

Control Rate
int32_t y1 = inlet_y1 + param_y1;
int32_t x1 = inlet_x1 + param_x1;
int32_t y2 = inlet_y2 + param_y2;
int32_t x2 = inlet_x2 + param_x2;

int32_t percent_Q27 =
    134217728.0f * ((float)(inlet_in - x1)) / ((float)(x2 - x1));
int32_t y = ___SMMLA(y2 - y1 << 2, percent_Q27 << 3, y1);

if (inlet_in < x1)
  outlet_out = y1;
else if (inlet_in > x2)
  outlet_out = y2;
else
  outlet_out = y;

Privacy

© 2024 Zrna Research