frac32.positive input value
frac32.positive interpolated output
frac32.s.map curve end tension
frac32.u.map curve start tension
__attribute__((always_inline)) __STATIC_INLINE float int2f(int32_t val) {
return val * (float)(1.0f / (1 << 27));
}
__attribute__((always_inline)) __STATIC_INLINE int32_t f2int(float val) {
return (int)(val * (float)(1 << 27));
}
// Transform inlet val to float in 0 > 1 range
float x = int2f(inlet_in);
// Transform curve a and b params to float in 0 > 1 range
float a = int2f(param_start);
float b = int2f(param_end);
// Cubic Bezier interpolation
// http://blog.demofox.org/2014/08/28/one-dimensional-bezier-curves/
float outf =
3 * ((1 - x) * (1 - x)) * x * a + 3 * (1 - x) * (x * x) * b + (x * x * x);
// Output int
outlet_out = f2int(outf);