From 62cd4d43bf75c6f1045754edc0b543358c598574 Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Wed, 20 Jul 2016 20:10:46 +1000 Subject: a-Comp: Fix bug with DSP in the knee processing region --- libs/plugins/a-comp.lv2/a-comp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/plugins/a-comp.lv2/a-comp.c b/libs/plugins/a-comp.lv2/a-comp.c index 616bee5956..3b123d24af 100644 --- a/libs/plugins/a-comp.lv2/a-comp.c +++ b/libs/plugins/a-comp.lv2/a-comp.c @@ -316,13 +316,14 @@ run_mono(LV2_Handle instance, uint32_t n_samples) Lxg = (ingain==0.f) ? -160.f : to_dB(ingain); Lxg = sanitize_denormal(Lxg); - Lyg = Lxg + (1.f/ratio-1.f)*(Lxg-thresdb+width/2.f)*(Lxg-thresdb+width/2.f)/(2.f*width); if (2.f*(Lxg-thresdb) < -width) { Lyg = Lxg; - } else { + } else if (2.f*(Lxg-thresdb) > width) { Lyg = thresdb + (Lxg-thresdb)/ratio; Lyg = sanitize_denormal(Lyg); + } else { + Lyg = Lxg + (1.f/ratio-1.f)*(Lxg-thresdb+width/2.f)*(Lxg-thresdb+width/2.f)/(2.f*width); } Lxl = Lxg - Lyg; @@ -432,13 +433,14 @@ run_stereo(LV2_Handle instance, uint32_t n_samples) Lxg = (ingain==0.f) ? -160.f : to_dB(ingain); Lxg = sanitize_denormal(Lxg); - Lyg = Lxg + (1.f/ratio-1.f)*(Lxg-thresdb+width/2.f)*(Lxg-thresdb+width/2.f)/(2.f*width); if (2.f*(Lxg-thresdb) < -width) { Lyg = Lxg; - } else { + } else if (2.f*(Lxg-thresdb) > width) { Lyg = thresdb + (Lxg-thresdb)/ratio; Lyg = sanitize_denormal(Lyg); + } else { + Lyg = Lxg + (1.f/ratio-1.f)*(Lxg-thresdb+width/2.f)*(Lxg-thresdb+width/2.f)/(2.f*width); } Lxl = Lxg - Lyg; @@ -524,10 +526,10 @@ comp_curve (AComp* self, float xg) { if (2.f * (xg - thresdb) < -width) { yg = xg; - } else if (2.f * fabs (xg - thresdb) <= width) { - yg = xg + (1.f / ratio - 1.f ) * (xg - thresdb + width / 2.f) * (xg - thresdb + width / 2.f) / (2.f * width); } else if (2.f * (xg - thresdb) > width) { yg = thresdb + (xg - thresdb) / ratio; + } else { + yg = xg + (1.f / ratio - 1.f ) * (xg - thresdb + width / 2.f) * (xg - thresdb + width / 2.f) / (2.f * width); } return yg; } -- cgit v1.2.3