diff options
author | Damien Zammit <damien@zamaudio.com> | 2017-11-11 13:59:41 +1100 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2017-11-11 14:26:50 +1100 |
commit | f3efff4c7ef92e5053a05e2eae25dd9ed6e8f395 (patch) | |
tree | 3309f513a0d6bec98c552b042e335d83c11b0f5b /libs | |
parent | 69603bb76e897706d60647c121d8aeb5313f2858 (diff) |
a-comp: Fix noise floor - asymptotics
Diffstat (limited to 'libs')
-rw-r--r-- | libs/plugins/a-comp.lv2/a-comp.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libs/plugins/a-comp.lv2/a-comp.c b/libs/plugins/a-comp.lv2/a-comp.c index e14f4ee004..06d4a6181c 100644 --- a/libs/plugins/a-comp.lv2/a-comp.c +++ b/libs/plugins/a-comp.lv2/a-comp.c @@ -83,7 +83,6 @@ typedef struct { float old_yg; float makeup_gain; - float tau; #ifdef LV2_EXTENDED LV2_Inline_Display_Image_Surface surf; @@ -126,7 +125,7 @@ instantiate(const LV2_Descriptor* descriptor, acomp->srate = rate; acomp->old_yl=acomp->old_y1=acomp->old_yg=0.f; - acomp->tau = (1.0 - exp (-2.f * M_PI * 25.f / acomp->srate)); + acomp->makeup_gain = 1.f; #ifdef LV2_EXTENDED acomp->need_expose = true; acomp->v_lvl_out = -70.f; @@ -291,7 +290,7 @@ run_mono(LV2_Handle instance, uint32_t n_samples) float makeup_target = from_dB(makeup); float makeup_gain = acomp->makeup_gain; - const float tau = acomp->tau; + const float tau = (1.0 - exp (-2.f * M_PI * n_samples * 25.f / acomp->srate)); if (*acomp->enable <= 0) { ratio = 1.f; @@ -363,7 +362,6 @@ run_mono(LV2_Handle instance, uint32_t n_samples) lgaininp = in0 * Lgain; - makeup_gain += tau * (makeup_target - makeup_gain) + 1e-12; output[i] = lgaininp * makeup_gain; max = (fabsf(output[i]) > max) ? fabsf(output[i]) : sanitize_denormal(max); @@ -375,6 +373,12 @@ run_mono(LV2_Handle instance, uint32_t n_samples) acomp->old_yg = Lyg; } + if ( fabsf(makeup_target - makeup_gain) < 1e-6 ) { + makeup_gain = 1.0; + } else { + makeup_gain += tau * (makeup_target - makeup_gain) + 1e-12; + } + *(acomp->outlevel) = (max < 0.0056f) ? -45.f : to_dB(max); acomp->makeup_gain = makeup_gain; @@ -441,7 +445,7 @@ run_stereo(LV2_Handle instance, uint32_t n_samples) float makeup_target = from_dB(makeup); float makeup_gain = acomp->makeup_gain; - const float tau = acomp->tau; + const float tau = (1.0 - exp (-2.f * M_PI * n_samples * 25.f / acomp->srate)); if (*acomp->enable <= 0) { ratio = 1.f; @@ -516,8 +520,6 @@ run_stereo(LV2_Handle instance, uint32_t n_samples) lgaininp = in0 * Lgain; rgaininp = in1 * Lgain; - makeup_gain += tau * (makeup_target - makeup_gain) + 1e-12; - output0[i] = lgaininp * makeup_gain; output1[i] = rgaininp * makeup_gain; @@ -530,6 +532,12 @@ run_stereo(LV2_Handle instance, uint32_t n_samples) acomp->old_yg = Lyg; } + if ( fabsf(makeup_target - makeup_gain) < 1e-6 ) { + makeup_gain = 1.0; + } else { + makeup_gain += tau * (makeup_target - makeup_gain) + 1e-12; + } + *(acomp->outlevel) = (max < 0.0056f) ? -45.f : to_dB(max); acomp->makeup_gain = makeup_gain; |