frac32.positive input value
frac32.positive interpolated output
spinner curve
// Convert from int32_t to float in 0 >1 range
// With thanks to Johannes for code
__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 param to float in 0 - 1 range
float a = int2f(attr_curve << 21);
// Reverse curve param
a = 1 - a;
// Interpolate between exp-like and log-like curves (without using pow())
// With thanks to Johannes for code
float outf =
a * (x * x * x * x) + (1 - a) * (1 - (1 - x) * (1 - x) * (1 - x) * (1 - x));
// Output int
outlet_out = f2int(outf);