Clean up double/float narrowing math in plugins.

This commit is contained in:
Robin Gareus 2020-03-30 21:59:07 +02:00
parent 070d8f5ee1
commit 3df530e7f6
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
3 changed files with 12 additions and 12 deletions

View file

@ -266,12 +266,12 @@ sanitize_denormal(float value) {
static inline float
from_dB(float gdb) {
return (exp(gdb/20.f*log(10.f)));
return powf (10.0f, 0.05f * gdb);
}
static inline float
to_dB(float g) {
return (20.f*log10(g));
return (20.f * log10f (g));
}
static void
@ -300,8 +300,8 @@ run(LV2_Handle instance, uint32_t n_samples)
float srate = acomp->srate;
float width = (6.f * *(acomp->knee)) + 0.01;
float attack_coeff = exp(-1000.f/(*(acomp->attack) * srate));
float release_coeff = exp(-1000.f/(*(acomp->release) * srate));
float attack_coeff = expf (-1000.f / (*(acomp->attack) * srate));
float release_coeff = expf (-1000.f / (*(acomp->release) * srate));
float max_out = 0.f;
float Lgain = 1.f;
@ -323,7 +323,7 @@ run(LV2_Handle instance, uint32_t n_samples)
float makeup_target = from_dB(makeup);
float makeup_gain = acomp->makeup_gain;
const float tau = (1.0 - exp (-2.f * M_PI * 25.f / acomp->srate));
const float tau = (1.f - expf (-2.f * M_PI * 25.f / acomp->srate));
if (*acomp->enable <= 0) {
ratio = 1.f;
@ -446,7 +446,7 @@ run(LV2_Handle instance, uint32_t n_samples)
if (acomp->v_gainr > knee_lim_gr) {
state_x = acomp->v_gainr / (1.f - 1.f/ratio) + thresdb;
} else {
state_x = sqrt ( (2.f*width*acomp->v_gainr) / (1.f-1.f/ratio) ) + thresdb - width/2.f;
state_x = sqrtf ( (2.f*width*acomp->v_gainr) / (1.f-1.f/ratio) ) + thresdb - width/2.f;
}
if (fabsf (acomp->v_lvl_out - v_lvl_out) >= .1f ||