knee h s

Continuous slope with two angular coefficients (knee shape). Knob determines the horizontal position of the knee. Mod input allows to edit the position live. S-rate
Author: Sputnki
License: BSD
Github: sptnk/math/knee h s.axo

Inlets

frac32buffer.positive in

frac32.bipolar mod

Outlets

frac32buffer.positive out

Parameters

frac32.u.map.gain amp

Declaration
uint32_t param;
Control Rate
/*
 * inlet_in=x
 * outlet_out=y
 *
 * param_amp= knob value ( ParameterFrac32UMapGain type)
 * inlet_mod= additional mod input value ( inletFrac32Bipolar type )
 * the param_amp and inlet_mod are then added to provide the K parameter
 */

param = param_amp + (inlet_mod << 4); // this is K
float fparam = (param >> 4);
Audio Rate
float temp;
float input = (inlet_in);

if (inlet_in < (param >> 4)) // if x<K -> output the first part of the ramp
                             // (this one works as intended)
{
  temp = (281474976710656.f / (fparam));
  outlet_out = ___SMMUL((int)(temp / 2), inlet_in) << 11;
} else // if x>K -> output the second part of the ramp (and here comes the
       // trouble, it does not work as expected at all)

{
  temp = (281474976710656.f / ((1 << 27) - fparam));
  outlet_out =
      (___SMMUL((int)(temp / 2), inlet_in - (param >> 4)) << 11) + (1 << 26);
}

Privacy

© 2024 Zrna Research