frac32buffer.positive in
frac32.bipolar mod
frac32buffer.positive out
frac32.u.map.gain amp
uint32_t param;
/*
* 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);
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);
}