frac32 in
frac32 out
frac32.u.map tresh
frac32.u.map ratio
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);
}
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);