Adjust the indication of the treshold value by the makup gain.
authorJohannes Mueller <github@johannes-mueller.org>
Sun, 18 Jun 2017 22:06:10 +0000 (00:06 +0200)
committerRobin Gareus <robin@gareus.org>
Mon, 31 Jul 2017 19:31:22 +0000 (21:31 +0200)
When lifting the compressor curve by the makeup gain value the actual
treshold (the level when the curve kinks in) is also lifted. Therefore we need
to adjust the dashed line indicating the threshold as well as the level when
the color gradient to show compression kicks in.

libs/plugins/a-comp.lv2/a-comp.c

index 4844c095a26166cb25bf7e391b3dc720d5c16864..6e2c37815ea4af266225b6368d0f5f4846322899 100644 (file)
@@ -588,6 +588,8 @@ render_inline (LV2_Handle instance, uint32_t w, uint32_t max_h)
        AComp* self = (AComp*)instance;
        uint32_t h = MIN (w, max_h);
 
+       const float makeup_thres = self->v_thresdb + self->v_makeup;
+
        if (!self->display || self->w != w || self->h != h) {
                if (self->display) cairo_surface_destroy(self->display);
                self->display = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h);
@@ -626,7 +628,7 @@ render_inline (LV2_Handle instance, uint32_t w, uint32_t max_h)
        }
        if (self->v_thresdb < 0) {
                cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 1.0);
-               const float y = -.5 + floorf (h * (self->v_thresdb / -60.f));
+               const float y = -.5 + floorf (h * (makeup_thres / -60.f));
                cairo_set_dash(cr, dash1, 2, 2);
                cairo_move_to (cr, 0, y);
                cairo_line_to (cr, w, y);
@@ -658,16 +660,16 @@ render_inline (LV2_Handle instance, uint32_t w, uint32_t max_h)
        // draw signal level & reduction/gradient
        const float top = comp_curve (self, 0);
        cairo_pattern_t* pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, h);
-       if (top > self->v_thresdb) {
+       if (top > makeup_thres) {
                cairo_pattern_add_color_stop_rgba (pat, 0.0, 0.8, 0.1, 0.1, 0.5);
                cairo_pattern_add_color_stop_rgba (pat, top / -60.f, 0.8, 0.1, 0.1, 0.5);
        }
        if (self->v_knee > 0) {
-               cairo_pattern_add_color_stop_rgba (pat, (self->v_thresdb / -60.f), 0.7, 0.7, 0.2, 0.5);
-               cairo_pattern_add_color_stop_rgba (pat, ((self->v_thresdb - self->v_knee) / -60.f), 0.5, 0.5, 0.5, 0.5);
+               cairo_pattern_add_color_stop_rgba (pat, (makeup_thres / -60.f), 0.7, 0.7, 0.2, 0.5);
+               cairo_pattern_add_color_stop_rgba (pat, ((makeup_thres - self->v_knee) / -60.f), 0.5, 0.5, 0.5, 0.5);
        } else {
-               cairo_pattern_add_color_stop_rgba (pat, (self->v_thresdb / -60.f), 0.7, 0.7, 0.2, 0.5);
-               cairo_pattern_add_color_stop_rgba (pat, ((self->v_thresdb - .01) / -60.f), 0.5, 0.5, 0.5, 0.5);
+               cairo_pattern_add_color_stop_rgba (pat, (makeup_thres / -60.f), 0.7, 0.7, 0.2, 0.5);
+               cairo_pattern_add_color_stop_rgba (pat, ((makeup_thres - .01) / -60.f), 0.5, 0.5, 0.5, 0.5);
        }
        cairo_pattern_add_color_stop_rgba (pat, 1.0, 0.5, 0.5, 0.5, 0.5);