SqrtMix4

A non linear "mixer". An input alone will not be distorted. Distortion occurs only when many inputs are active. The output is the square root of the sum of the input squares. Note: the "square" and "squaroots" are "signed" i.e for negative values they are -x*x and -sqrt(-x*x).
Author: Smashed Transistors
License: LGPL
Github: tiar/dist/SqrtMix4.axo

Inlets

frac32buffer w

frac32buffer x

frac32buffer y

frac32buffer z

Outlets

frac32buffer.bipolar out

Parameters

frac32.u.map.gain Gw

frac32.u.map.gain Gx

frac32.u.map.gain Gy

frac32.u.map.gain Gz

Declaration
float s;
int32_t out2;
Init
s = 1.0f / (1 << 11);
out2 = 0;
Audio Rate
float out = _VSQRTF(out2);
// prepare next out2
// (integer instructions executed in parallel of sqrtf)
{
  int32_t t;
  t = ___SMMUL(inlet_w, param_Gw);
  out2 = ___SMMUL(t, abs(t));
  t = ___SMMUL(inlet_x, param_Gx);
  out2 = ___SMMLA(t, abs(t), out2);
  t = ___SMMUL(inlet_y, param_Gy);
  out2 = ___SMMLA(t, abs(t), out2);
  t = ___SMMUL(inlet_z, param_Gz);
  out2 = ___SMMLA(t, abs(t), out2);
}
{
  bool neg;
  if (neg = (out2 < 0))
    out2 = -out2;

  outlet_out = (int32_t)(s * out);

  s = neg ? -1.0f * (1 << 17) : 1.0f * (1 << 17);
}

Privacy

© 2024 Zrna Research