diff options
author | Johannes Mueller <github@johannes-mueller.org> | 2017-07-13 17:23:16 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-07-31 21:31:22 +0200 |
commit | 24cbb1b153ad2b380c3e5d5f51913fd93ff0a4fb (patch) | |
tree | fa23e554e1697960b2db07beba6d357b7b8641d3 /libs/plugins/a-comp.lv2 | |
parent | ccab32654b97366c398bc9fcfedab8a2e630e1ef (diff) |
Honor attack and release parameters in a-comp's inline graph
Diffstat (limited to 'libs/plugins/a-comp.lv2')
-rw-r--r-- | libs/plugins/a-comp.lv2/a-comp.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libs/plugins/a-comp.lv2/a-comp.c b/libs/plugins/a-comp.lv2/a-comp.c index 615646d943..bb282f962c 100644 --- a/libs/plugins/a-comp.lv2/a-comp.c +++ b/libs/plugins/a-comp.lv2/a-comp.c @@ -102,6 +102,7 @@ typedef struct { float v_gainr; float v_makeup; float v_lvl; + float v_lv1; float v_lvl_in; float v_lvl_out; #endif @@ -377,7 +378,13 @@ run_mono(LV2_Handle instance, uint32_t n_samples) acomp->makeup_gain = makeup_gain; #ifdef LV2_EXTENDED - acomp->v_lvl += .1 * (in_peak - acomp->v_lvl) + 1e-12; // crude LPF TODO use n_samples/rate TC + const float old_v_lv1 = acomp->v_lv1; + const float old_v_lvl = acomp->v_lvl; + const float tot_rel_c = exp(-1000.f/(*(acomp->release) * srate) * n_samples); + const float tot_atk_c = exp(-1000.f/(*(acomp->attack) * srate) * n_samples); + acomp->v_lv1 = fmaxf (in_peak, tot_rel_c*old_v_lv1 + (1.f-tot_rel_c)*in_peak); + acomp->v_lvl = tot_atk_c*old_v_lvl + (1.f-tot_atk_c)*acomp->v_lv1; + if (!isfinite_local (acomp->v_lvl)) { acomp->v_lvl = 0.f; } @@ -525,7 +532,12 @@ run_stereo(LV2_Handle instance, uint32_t n_samples) acomp->makeup_gain = makeup_gain; #ifdef LV2_EXTENDED - acomp->v_lvl += .1 * (in_peak - acomp->v_lvl) + 1e-12; // crude LPF TODO use n_samples/rate TC + const float old_v_lv1 = acomp->v_lv1; + const float old_v_lvl = acomp->v_lvl; + const float tot_rel_c = exp(-1000.f/(*(acomp->release) * srate) * n_samples); + const float tot_atk_c = exp(-1000.f/(*(acomp->attack) * srate) * n_samples); + acomp->v_lv1 = fmaxf (in_peak, tot_rel_c*old_v_lv1 + (1.f-tot_rel_c)*in_peak); + acomp->v_lvl = tot_atk_c*old_v_lvl + (1.f-tot_atk_c)*acomp->v_lv1; if (!isfinite_local (acomp->v_lvl)) { acomp->v_lvl = 0.f; } |