compand

Compander (inverse function of the "expand" object). Differentiated Anti aliasing.
Author: Smashed Transistors
License: BSD
Github: tiar/dist/compand.axo

Inlets

frac32buffer.bipolar in

Outlets

frac32buffer out

Declaration
float x0, x1, y0, y1;
Init
x0 = y0 = 0;
Audio Rate
x1 = x0;
y1 = y0;
x0 = arm::q_to_float(inlet_in, 27);
float _x0 = fabs(x0);
float sgn = x0 >= 0 ? 1 : -1;
float sqrt = arm::vsqrtf(_x0);
y0 = (2.0f / 3) * _x0 * sqrt;
float x1_x0 = x1 - x0;
if (fabs(x1_x0) > 0.001f) {
  outlet_out = arm::float_to_q((y1 - y0) / (x1_x0), 27);
} else {
  outlet_out = arm::float_to_q(sgn * sqrt, 27);
}

Privacy

© 2024 Zrna Research