summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2016-07-20 20:10:46 +1000
committerDamien Zammit <damien@zamaudio.com>2016-07-20 20:10:46 +1000
commit62cd4d43bf75c6f1045754edc0b543358c598574 (patch)
treeb5da25c9781d8fbf82c294cfb03b76aa1de1fdf6
parent85cdff7cb01dc7a9bb61200d36b9b7c11c9e75d1 (diff)
a-Comp: Fix bug with DSP in the knee processing region
-rw-r--r--libs/plugins/a-comp.lv2/a-comp.c14
1 files 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;
}