interpolation-pow4

pow4 interpolation
Author: toneburst
License: BSD
Github: toneburst/math/interpolation pow4.axo

Inlets

frac32.positive input value

Outlets

frac32.positive interpolated output

Parameters

frac32.u.map interpolation curve

Declaration
// 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));
}
Control Rate
// 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(param_curve);
// 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);

Privacy

© 2024 Zrna Research