comp

Dynamic range compressor. Gain calculation only. Envelope follower, attack, decay and VCA are not included.
Author: Johannes Taelman
License: BSD
Github: dyn/comp.axo

Inlets

frac32 in

Outlets

frac32 out

Parameters

frac32.u.map tresh

frac32.u.map ratio

Declaration
int32_t frac_log(int32_t a) {
  Float_t f;
  f.f = a;
  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
int32_t inlog = frac_log(inlet_in);
int32_t treshlog = frac_log(param_tresh);
int32_t over = inlog - treshlog;
int32_t gain;
if (over < 0) {
  gain = 0x80000;
} else {
  gain = frac_exp(-___SMMUL(over, param_ratio) << 5);
}
outlet_out = gain << 8; //___SMMUL(inlet_in,gain);

Privacy

© 2024 Zrna Research