summaryrefslogtreecommitdiff
path: root/libs/plugins
diff options
context:
space:
mode:
authorJohannes Mueller <github@johannes-mueller.org>2018-06-09 18:50:43 +0200
committerJohannes Mueller <github@johannes-mueller.org>2018-06-20 22:10:54 +0200
commit65fed2fa898c9acb0a7fdf0a1116d77219673275 (patch)
tree7d22bd6300286597d332f955c2903c6bee35801b /libs/plugins
parent4b37e248e1e958b68798a35c24b8209044a89f0e (diff)
Make makeup_gain smoothening of a-expander same as in a-comp
Diffstat (limited to 'libs/plugins')
-rw-r--r--libs/plugins/a-exp.lv2/a-exp.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/libs/plugins/a-exp.lv2/a-exp.c b/libs/plugins/a-exp.lv2/a-exp.c
index 7365386567..6e748b5877 100644
--- a/libs/plugins/a-exp.lv2/a-exp.c
+++ b/libs/plugins/a-exp.lv2/a-exp.c
@@ -43,6 +43,11 @@
#define isfinite_local isfinite
#endif
+#ifndef FLT_EPSILON
+# define FLT_EPSILON 1.192093e-07
+#endif
+
+
typedef enum {
AEXP_ATTACK = 0,
AEXP_RELEASE,
@@ -87,7 +92,6 @@ typedef struct {
float srate;
float makeup_gain;
- float tau;
bool was_disabled;
@@ -132,7 +136,6 @@ instantiate(const LV2_Descriptor* descriptor,
}
aexp->srate = rate;
- aexp->tau = (1.0 - exp (-2.f * M_PI * 25.f / aexp->srate));
#ifdef LV2_EXTENDED
aexp->need_expose = true;
aexp->v_lvl_out = -70.f;
@@ -306,7 +309,7 @@ run_mono(LV2_Handle instance, uint32_t n_samples)
float makeup_target = from_dB(makeup);
float makeup_gain = aexp->makeup_gain;
- const float tau = aexp->tau;
+ const float tau = (1.0 - exp (-2.f * M_PI * 25.f / aexp->srate));
if (*aexp->enable <= 0) {
ratio = 1.f;
@@ -395,12 +398,16 @@ run_mono(LV2_Handle instance, uint32_t n_samples)
lgaininp = in0 * Lgain;
- makeup_gain += tau * (makeup_target - makeup_gain) + 1e-12;
+ makeup_gain += tau * (makeup_target - makeup_gain);
output[i] = lgaininp * makeup_gain;
max = (fabsf(output[i]) > max) ? fabsf(output[i]) : sanitize_denormal(max);
}
+ if (fabsf(tau * (makeup_gain - makeup_target)) < FLT_EPSILON*makeup_gain) {
+ makeup_gain = makeup_target;
+ }
+
*(aexp->outlevel) = (max < 0.0056f) ? -45.f : to_dB(max);
*(aexp->inlevel) = in_peak_db;
aexp->makeup_gain = makeup_gain;
@@ -476,7 +483,7 @@ run_stereo(LV2_Handle instance, uint32_t n_samples)
float makeup_target = from_dB(makeup);
float makeup_gain = aexp->makeup_gain;
- const float tau = aexp->tau;
+ const float tau = (1.0 - exp (-2.f * M_PI * 25.f / aexp->srate));
if (*aexp->enable <= 0) {
ratio = 1.f;
@@ -569,7 +576,7 @@ run_stereo(LV2_Handle instance, uint32_t n_samples)
lgaininp = in0 * Lgain;
rgaininp = in1 * Lgain;
- makeup_gain += tau * (makeup_target - makeup_gain) + 1e-12;
+ makeup_gain += tau * (makeup_target - makeup_gain);
output0[i] = lgaininp * makeup_gain;
output1[i] = rgaininp * makeup_gain;
@@ -577,6 +584,10 @@ run_stereo(LV2_Handle instance, uint32_t n_samples)
max = (fmaxf(fabs(output0[i]), fabs(output1[i])) > max) ? fmaxf(fabs(output0[i]), fabs(output1[i])) : sanitize_denormal(max);
}
+ if (fabsf(tau * (makeup_gain - makeup_target)) < FLT_EPSILON*makeup_gain) {
+ makeup_gain = makeup_target;
+ }
+
*(aexp->outlevel) = (max < 0.0056f) ? -45.f : to_dB(max);
*(aexp->inlevel) = in_peak_db;
aexp->makeup_gain = makeup_gain;