diff options
author | Johannes Mueller <github@johannes-mueller.org> | 2017-08-03 22:20:07 +0200 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2017-10-11 18:23:56 +1100 |
commit | d437f9570e3eac0d0602a424d433d10d84b87a9d (patch) | |
tree | 28a0d31ec8e1a9588425e2df1c35a7421d3cd7bd /plugins/ZamCompX2 | |
parent | 577fb21ac32b8fa4efe3d22b48fcb5283fd4be11 (diff) |
compressors: Make the attack no longer influence the release.
Before this change, setting a low release time and a high attack time
made any compressor also release slowly (according to the attack parameter).
This commit changes this behavior so that the attack parameter
only affects the attack without affecting the release.
Signed-off-by: Damien Zammit <damien@zamaudio.com>
Diffstat (limited to 'plugins/ZamCompX2')
-rw-r--r-- | plugins/ZamCompX2/ZamCompX2Plugin.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/plugins/ZamCompX2/ZamCompX2Plugin.cpp b/plugins/ZamCompX2/ZamCompX2Plugin.cpp index 78fc43d..330b1b5 100644 --- a/plugins/ZamCompX2/ZamCompX2Plugin.cpp +++ b/plugins/ZamCompX2/ZamCompX2Plugin.cpp @@ -322,8 +322,8 @@ void ZamCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames float rgaininp = 0.f; float Lgain = 1.f; float Rgain = 1.f; - float Lxg, Lxl, Lyg, Lyl, Ly1; - float Rxg, Rxl, Ryg, Ryl, Ry1; + float Lxg, Lxl, Lyg, Lyl; + float Rxg, Rxl, Ryg, Ryl; float checkwidth = 0.f; uint32_t i; float in0; @@ -393,13 +393,14 @@ void ZamCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames Lxl = Rxl = (Lxg - Lyg + Rxg - Ryg) / 2.f; } - oldL_y1 = sanitize_denormal(oldL_y1); - oldR_y1 = sanitize_denormal(oldR_y1); oldL_yl = sanitize_denormal(oldL_yl); - oldR_yl = sanitize_denormal(oldR_yl); - Ly1 = fmaxf(Lxl, release_coeff * oldL_y1+(1.f-release_coeff)*Lxl); - Lyl = attack_coeff * oldL_yl+(1.f-attack_coeff)*Ly1; - Ly1 = sanitize_denormal(Ly1); + if (Lxl < oldL_yl) { + Lyl = release_coeff * oldL_yl + (1.f-release_coeff)*Lxl; + } else if (Lxl > oldL_yl) { + Lyl = attack_coeff * oldL_yl+(1.f-attack_coeff)*Lxl; + } else { + Lyl = Lxl; + } Lyl = sanitize_denormal(Lyl); cdb = -Lyl; @@ -407,9 +408,14 @@ void ZamCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames gainred = Lyl; - Ry1 = fmaxf(Rxl, release_coeff * oldR_y1+(1.f-release_coeff)*Rxl); - Ryl = attack_coeff * oldR_yl+(1.f-attack_coeff)*Ry1; - Ry1 = sanitize_denormal(Ry1); + oldR_y1 = sanitize_denormal(oldR_y1); + if (Rxl < oldR_yl) { + Ryl = release_coeff * oldR_yl + (1.f-release_coeff)*Rxl; + } else if (Rxl > oldR_yl) { + Ryl = attack_coeff * oldR_yl+(1.f-attack_coeff)*Rxl; + } else { + Ryl = Rxl; + } Ryl = sanitize_denormal(Ryl); cdb = -Ryl; @@ -424,8 +430,6 @@ void ZamCompX2Plugin::run(const float** inputs, float** outputs, uint32_t frames oldL_yl = Lyl; oldR_yl = Ryl; - oldL_y1 = Ly1; - oldR_y1 = Ry1; oldL_yg = Lyg; oldR_yg = Ryg; } |