softComp

Dynamic range compressor with soft-treshold function. It does direction compression, that means, no attack/release or envelope functioning inside!
Author: Remco van der Most
License: BSD
Github: sss/dist/softComp.axo

Inlets

frac32buffer in

Outlets

frac32buffer out

Parameters

frac32.u.map pre

frac32.u.map tresh

frac32.u.map soft

frac32.u.map ratio

frac32.u.map out

Declaration
int32_t frac_log(int32_t a) {
  Float_t f;
  f.f = a;
  // a=a>0?a:-1;
  int32_t r1 = ((f.parts.exponent & 0x7F) - 18) << 24;
  int32_t r3 = logt[f.parts.mantissa >> 15] << 10;
  return r1 + r3;
}

int32_t frac_exp(int32_t a) {
  int8_t s = (a >> 24) + 4;
  uint8_t ei = a >> 16;
  if (s >= 0)
    return expt[ei] << s;
  else
    return expt[ei] >> (-s);
}
Control Rate
if (param_tresh < (param_soft >> 1)) {
  PExParameterChange(&parent->PExch[PARAM_INDEX_attr_legal_name_tresh],
                     param_soft >> 1, 0xFFFD);
}

int32_t soft = ___SMMUL(param_tresh << 3, param_soft << 1) + (8 << 21);
int32_t treshlog = frac_log(param_tresh - soft);
int32_t Tresh = frac_log(param_tresh);
Tresh = Tresh - treshlog;
float32_t ratio = (float32_t)(1 << 27) / Tresh;
int32_t makeup = frac_log(param_out) - (treshlog);
makeup = frac_exp(makeup);
Audio Rate
int32_t In = inlet_in >> 4;
In = __SSAT(In + ___SMMUL(inlet_in, param_pre << 4), 29) << 3;
int32_t IN = In;
IN = IN > 0 ? IN : -IN;
int32_t inlog = frac_log(IN);
int32_t over1 = inlog - treshlog;
int32_t over2 = __USAT((over1 >> 1) * ratio, 27);
int32_t gain;
if (over1 < 0) {
  gain = 0x80000;
} else {
  gain =
      frac_exp(-___SMMUL(over1, ___SMMUL(over2 << 3, param_ratio << 2)) << 5);
}
outlet_out = ___SMMUL(___SMMUL(In, gain << 10) << 6, makeup << 10);

Privacy

© 2024 Zrna Research