[SCM] calf/master: New widget: Tube with light and falloff

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:39:42 UTC 2013


The following commit has been merged in the master branch:
commit 0d7001ca5ff98352e7f1c28c862426c59c961984
Author: Markus Schmidt <schmidt at boomshop.net>
Date:   Thu Oct 29 06:35:54 2009 +0100

    New widget: Tube with light and falloff

diff --git a/gui/gui-deesser.xml b/gui/gui-deesser.xml
index 7519c73..621d623 100644
--- a/gui/gui-deesser.xml
+++ b/gui/gui-deesser.xml
@@ -9,10 +9,10 @@
             <vumeter param="compression" mode="2" hold="1.5" falloff="2.5" attach-x="1" attach-y="2" />
             <label param="compression" attach-x="1" attach-y="3" />
             
-            <label param="detected_led" attach-x="2" attach-y="0" expand-x="0" fill-x="0" />
-            <led param="detected_led" attach-x="2" attach-y="1" expand-x="0" fill-x="0" />
-            <led param="clip_out" mode="6" attach-x="2" attach-y="2" expand-x="0" fill-x="0" />
-            <label param="clip_out" attach-x="2" attach-y="3" expand-x="0" fill-x="0" />
+            <label param="clip_out" attach-x="2" attach-y="0" expand-x="0" fill-x="0" />
+            <led param="clip_out" mode="6" attach-x="2" attach-y="1" expand-x="0" fill-x="0" />
+            <led param="detected_led" attach-x="2" attach-y="2" expand-x="0" fill-x="0" />
+            <label param="detected_led" attach-x="2" attach-y="3" expand-x="0" fill-x="0" />
             
             <label param="sc_listen" attach-x="3" attach-y="0" expand-x="0" fill-x="0" />
             <toggle param="sc_listen" attach-x="3" attach-y="1" attach-h="2" expand-x="0" fill-x="0" />
diff --git a/gui/tubeH1.png b/gui/tubeH1.png
new file mode 100644
index 0000000..c215797
Binary files /dev/null and b/gui/tubeH1.png differ
diff --git a/gui/tubeH2.png b/gui/tubeH2.png
new file mode 100644
index 0000000..1b646c4
Binary files /dev/null and b/gui/tubeH2.png differ
diff --git a/gui/tubeV1.png b/gui/tubeV1.png
new file mode 100644
index 0000000..13219ca
Binary files /dev/null and b/gui/tubeV1.png differ
diff --git a/gui/tubeV2.png b/gui/tubeV2.png
new file mode 100644
index 0000000..71e00ad
Binary files /dev/null and b/gui/tubeV2.png differ
diff --git a/src/calf/custom_ctl.h b/src/calf/custom_ctl.h
index f401712..fa09bf7 100644
--- a/src/calf/custom_ctl.h
+++ b/src/calf/custom_ctl.h
@@ -140,6 +140,8 @@ struct CalfToggle
 {
     GtkRange parent;
     int size;
+    int width;
+    int height;
 };
 
 struct CalfToggleClass
@@ -153,6 +155,36 @@ extern GtkWidget *calf_toggle_new_with_adjustment(GtkAdjustment *_adjustment);
 
 extern GType calf_toggle_get_type();
 
+#define CALF_TYPE_TUBE           (calf_tube_get_type())
+#define CALF_TUBE(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), CALF_TYPE_TUBE, CalfTube))
+#define CALF_IS_TUBE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CALF_TYPE_TUBE))
+#define CALF_TUBE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass),  CALF_TYPE_TUBE, CalfTubeClass))
+#define CALF_IS_TUBE_CLASS(obj)  (G_TYPE_CHECK_CLASS_TYPE ((klass),  CALF_TYPE_TUBE))
+#define CALF_TUBE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),  CALF_TYPE_TUBE, CalfTubeClass))
+
+struct CalfTube
+{
+    GtkDrawingArea parent;
+    int size;
+    int direction;
+    float value;
+    float last_value;
+    float tube_falloff;
+    bool falling;
+    float last_falloff;
+    long last_falltime;
+    cairo_surface_t *cache_surface;
+};
+
+struct CalfTubeClass
+{
+    GtkDrawingAreaClass parent_class;
+};
+
+extern GtkWidget *calf_tube_new();
+extern GType calf_tube_get_type();
+extern void calf_tube_set_value(CalfTube *tube, float value);
+
 G_END_DECLS
 
 class cairo_impl: public calf_plugins::cairo_iface
diff --git a/src/calf/gui_controls.h b/src/calf/gui_controls.h
index 667f5b5..150f9a3 100644
--- a/src/calf/gui_controls.h
+++ b/src/calf/gui_controls.h
@@ -106,6 +106,14 @@ struct led_param_control: public param_control
     virtual void set();
 };
 
+/// Display-only control: tube
+struct tube_param_control: public param_control
+{
+    virtual GtkWidget *create(plugin_gui *_gui, int _param_no);
+    virtual void get() {}
+    virtual void set();
+};
+
 /// Horizontal slider
 struct hscale_param_control: public param_control
 {
diff --git a/src/calf/modules.h b/src/calf/modules.h
index 8612106..1907572 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -1063,6 +1063,7 @@ private:
     float f1_freq_old1, f2_freq_old1, f1_level_old1, f2_level_old1, f2_q_old1;
     uint32_t detected_led;
     float detected, clip_out;
+    uint32_t clip_led;
     gain_reduction_audio_module compressor;
     biquad_d2<float> hpL, hpR, lpL, lpR, pL, pR;
 public:
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index 751810c..4ddf32c 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -1265,3 +1265,329 @@ calf_toggle_get_type (void)
     }
     return type;
 }
+
+///////////////////////////////////////// tube ///////////////////////////////////////////////
+
+static gboolean
+calf_tube_expose (GtkWidget *widget, GdkEventExpose *event)
+{
+    g_assert(CALF_IS_TUBE(widget));
+    
+    CalfTube  *self   = CALF_TUBE(widget);
+    GdkWindow *window = widget->window;
+    GtkStyle  *style  = gtk_widget_get_style(widget);
+    cairo_t *c = gdk_cairo_create(GDK_DRAWABLE(window));
+    
+    int ox = 4, oy = 4, inner = 1, rad, pad;
+    int sx = widget->allocation.width - (ox * 2), sy = widget->allocation.height - (oy * 2);
+    
+    if( self->cache_surface == NULL ) {
+        // looks like its either first call or the widget has been resized.
+        // create the cache_surface.
+        cairo_surface_t *window_surface = cairo_get_target( c );
+        self->cache_surface = cairo_surface_create_similar( window_surface, 
+                                  CAIRO_CONTENT_COLOR,
+                                  widget->allocation.width,
+                                  widget->allocation.height );
+
+        // And render the meterstuff again.
+        cairo_t *cache_cr = cairo_create( self->cache_surface );
+        // theme background for reduced width and round borders
+//        if(widget->style->bg_pixmap[0] == NULL) {
+            gdk_cairo_set_source_color(cache_cr,&style->bg[GTK_STATE_NORMAL]);
+//        } else {
+//            gdk_cairo_set_source_pixbuf(cache_cr, GDK_PIXBUF(widget->style->bg_pixmap[0]), widget->allocation.x, widget->allocation.y + 20);
+//        }
+        cairo_paint(cache_cr);
+        
+        // outer (light)
+        pad = 0;
+        rad = 6;
+        cairo_arc(cache_cr, rad + pad, rad + pad, rad, 0, 2 * M_PI);
+        cairo_arc(cache_cr, ox * 2 + sx - rad - pad, rad + pad, rad, 0, 2 * M_PI);
+        cairo_arc(cache_cr, rad + pad, oy * 2 + sy - rad - pad, rad, 0, 2 * M_PI);
+        cairo_arc(cache_cr, ox * 2 + sx - rad - pad, oy * 2 + sy - rad - pad, rad, 0, 2 * M_PI);
+        cairo_rectangle(cache_cr, pad, rad + pad, sx + ox * 2 - pad * 2, sy + oy * 2 - rad * 2 - pad * 2);
+        cairo_rectangle(cache_cr, rad + pad, pad, sx + ox * 2 - rad * 2 - pad * 2, sy + oy * 2 - pad * 2);
+        cairo_pattern_t *pat2 = cairo_pattern_create_linear (0, 0, 0, sy + oy * 2 - pad * 2);
+        cairo_pattern_add_color_stop_rgba (pat2, 0, 0, 0, 0, 0.3);
+        cairo_pattern_add_color_stop_rgba (pat2, 1, 1, 1, 1, 0.6);
+        cairo_set_source (cache_cr, pat2);
+        cairo_fill(cache_cr);
+        
+        // inner (black)
+        pad = 1;
+        rad = 5;
+        cairo_arc(cache_cr, rad + pad, rad + pad, rad, 0, 2 * M_PI);
+        cairo_arc(cache_cr, ox * 2 + sx - rad - pad, rad + pad, rad, 0, 2 * M_PI);
+        cairo_arc(cache_cr, rad + pad, oy * 2 + sy - rad - pad, rad, 0, 2 * M_PI);
+        cairo_arc(cache_cr, ox * 2 + sx - rad - pad, oy * 2 + sy - rad - pad, rad, 0, 2 * M_PI);
+        cairo_rectangle(cache_cr, pad, rad + pad, sx + ox * 2 - pad * 2, sy + oy * 2 - rad * 2 - pad * 2);
+        cairo_rectangle(cache_cr, rad + pad, pad, sx + ox * 2 - rad * 2 - pad * 2, sy + oy * 2 - pad * 2);
+        pat2 = cairo_pattern_create_linear (0, 0, 0, sy + oy * 2 - pad * 2);
+        cairo_pattern_add_color_stop_rgba (pat2, 0, 0.23, 0.23, 0.23, 1);
+        cairo_pattern_add_color_stop_rgba (pat2, 0.5, 0, 0, 0, 1);
+        cairo_set_source (cache_cr, pat2);
+        //cairo_set_source_rgb(cache_cr, 0, 0, 0);
+        cairo_fill(cache_cr);
+        cairo_pattern_destroy(pat2);
+        
+        cairo_rectangle(cache_cr, ox, oy, sx, sy);
+        cairo_set_source_rgb (cache_cr, 0, 0, 0);
+        cairo_fill(cache_cr);
+        
+        cairo_surface_t *image;
+        switch(self->direction) {
+            case 1:
+                // vertical
+                switch(self->size) {
+                    default:
+                    case 1:
+                        image = cairo_image_surface_create_from_png (PKGLIBDIR "tubeV1.png");
+                        break;
+                    case 2:
+                        image = cairo_image_surface_create_from_png (PKGLIBDIR "tubeV2.png");
+                        break;
+                }
+                break;
+            default:
+            case 2:
+                // horizontal
+                switch(self->size) {
+                    default:
+                    case 1:
+                        image = cairo_image_surface_create_from_png (PKGLIBDIR "tubeH1.png");
+                        break;
+                    case 2:
+                        image = cairo_image_surface_create_from_png (PKGLIBDIR "tubeH2.png");
+                        break;
+                }
+                break;
+        }
+        cairo_set_source_surface (cache_cr, image, widget->allocation.width / 2 - sx / 2 + inner, widget->allocation.height / 2 - sy / 2 + inner);
+        cairo_paint (cache_cr);
+        cairo_surface_destroy (image);
+        cairo_destroy( cache_cr );
+    }
+    
+    cairo_set_source_surface( c, self->cache_surface, 0,0 );
+    cairo_paint( c );
+    
+    // get microseconds
+    timeval tv;
+    gettimeofday(&tv, 0);
+    long time = tv.tv_sec * 1000 * 1000 + tv.tv_usec;
+    
+    // limit to 1.f
+    float value_orig = self->value > 1.f ? 1.f : self->value;
+    value_orig = value_orig < 0.f ? 0.f : value_orig;
+    float value = 0.f;
+    
+    float s = ((float)(time - self->last_falltime) / 1000000.0);
+    float m = self->last_falloff * s * 2.5;
+    self->last_falloff -= m;
+    // new max value?
+    if(value_orig > self->last_falloff) {
+        self->last_falloff = value_orig;
+    }
+    value = self->last_falloff;
+    self->last_falltime = time;
+    self->falling = self->last_falloff > 0.000001;
+    cairo_pattern_t *pat;
+    // draw upper light
+    switch(self->direction) {
+        case 1:
+            // vertical
+            cairo_arc(c, ox + sx * 0.5, oy + sy * 0.3, sx, 0, 2 * M_PI);
+            pat = cairo_pattern_create_radial (ox + sx * 0.5, oy + sy * 0.3, 3, ox + sx * 0.5, oy + sy * 0.3, sx);
+            break;
+        default:
+        case 2:
+            // horizontal
+            cairo_arc(c, ox + sx * 0.7, oy + sy * 0.5, sy, 0, 2 * M_PI);
+            pat = cairo_pattern_create_radial (ox + sx * 0.7, oy + sy * 0.5, 3, ox + sx * 0.7, oy + sy * 0.5, sy);
+            break;
+    }
+    cairo_pattern_add_color_stop_rgba (pat, 0,    1,    1,    1,    value);
+    cairo_pattern_add_color_stop_rgba (pat, 0.3,  1,   0.8,  0.3, value * 0.4);
+    cairo_pattern_add_color_stop_rgba (pat, 0.31, 0.9, 0.5,  0.1,  value * 0.5);
+    cairo_pattern_add_color_stop_rgba (pat, 1,    0.0, 0.2,  0.7,  0);
+    cairo_set_source (c, pat);
+    cairo_fill(c);
+    // draw lower light
+    switch(self->direction) {
+        case 1:
+            // vertical
+            cairo_arc(c, ox + sx * 0.5, oy + sy * 0.8, sx / 2, 0, 2 * M_PI);
+            pat = cairo_pattern_create_radial (ox + sx * 0.5, oy + sy * 0.8, 2, ox + sx * 0.5, oy + sy * 0.8, sx / 2);
+            break;
+        default:
+        case 2:
+            // horizontal
+            cairo_arc(c, ox + sx / 5, oy + sy * 0.5, sy / 2, 0, 2 * M_PI);
+            pat = cairo_pattern_create_radial (ox + sx / 5, oy + sy * 0.5, 2, ox + sx / 5, oy + sy * 0.5, sy / 2);
+            break;
+    }
+    cairo_pattern_add_color_stop_rgba (pat, 0,    1,    1,    1,    value);
+    cairo_pattern_add_color_stop_rgba (pat, 0.3,  1,   0.8,  0.3, value * 0.4);
+    cairo_pattern_add_color_stop_rgba (pat, 0.31, 0.9, 0.5,  0.1,  value * 0.5);
+    cairo_pattern_add_color_stop_rgba (pat, 1,    0.0, 0.2,  0.7,  0);
+    cairo_set_source (c, pat);
+    cairo_fill(c);
+    
+    return TRUE;
+}
+
+static void
+calf_tube_size_request (GtkWidget *widget,
+                           GtkRequisition *requisition)
+{
+    g_assert(CALF_IS_TUBE(widget));
+
+    CalfTube *self = CALF_TUBE(widget);
+    switch(self->direction) {
+        case 1:
+            switch(self->size) {
+                case 1:
+                    widget->requisition.width = 70;
+                    widget->requisition.height = 130;
+                    break;
+                default:
+                case 2:
+                    widget->requisition.width = 110;
+                    widget->requisition.height = 210;
+                    break;
+            }
+            break;
+        default:
+        case 2:
+            switch(self->size) {
+                case 1:
+                    widget->requisition.width = 130;
+                    widget->requisition.height = 70;
+                    break;
+                default:
+                case 2:
+                    widget->requisition.width = 210;
+                    widget->requisition.height = 110;
+                    break;
+            }
+            break;
+    }
+}
+
+static void
+calf_tube_size_allocate (GtkWidget *widget,
+                           GtkAllocation *allocation)
+{
+    g_assert(CALF_IS_TUBE(widget));
+    CalfTube *tube = CALF_TUBE(widget);
+    
+    GtkWidgetClass *parent_class = (GtkWidgetClass *) g_type_class_peek_parent( CALF_TUBE_GET_CLASS( tube ) );
+
+    parent_class->size_allocate( widget, allocation );
+
+    if( tube->cache_surface )
+        cairo_surface_destroy( tube->cache_surface );
+    tube->cache_surface = NULL;
+}
+
+static void
+calf_tube_class_init (CalfTubeClass *klass)
+{
+    // GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+    GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+    widget_class->expose_event = calf_tube_expose;
+    widget_class->size_request = calf_tube_size_request;
+    widget_class->size_allocate = calf_tube_size_allocate;
+}
+
+static void
+calf_tube_init (CalfTube *self)
+{
+    GtkWidget *widget = GTK_WIDGET(self);
+    GTK_WIDGET_SET_FLAGS (GTK_WIDGET(self), GTK_CAN_FOCUS);
+    switch(self->direction) {
+        case 1:
+            switch(self->size) {
+                case 1:
+                    widget->requisition.width = 70;
+                    widget->requisition.height = 130;
+                    break;
+                default:
+                case 2:
+                    widget->requisition.width = 110;
+                    widget->requisition.height = 210;
+                    break;
+            }
+            break;
+        default:
+        case 2:
+            switch(self->size) {
+                case 1:
+                    widget->requisition.width = 130;
+                    widget->requisition.height = 70;
+                    break;
+                default:
+                case 2:
+                    widget->requisition.width = 210;
+                    widget->requisition.height = 110;
+                    break;
+            }
+            break;
+    }
+    self->falling = false;
+    self->cache_surface = NULL;
+}
+
+GtkWidget *
+calf_tube_new()
+{
+    GtkWidget *widget = GTK_WIDGET( g_object_new (CALF_TYPE_TUBE, NULL ));
+    return widget;
+}
+
+extern void calf_tube_set_value(CalfTube *tube, float value)
+{
+    if (value != tube->value or tube->falling)
+    {
+        tube->value = value;
+        gtk_widget_queue_draw(GTK_WIDGET(tube));
+    }
+}
+
+GType
+calf_tube_get_type (void)
+{
+    static GType type = 0;
+    if (!type) {
+        
+        static const GTypeInfo type_info = {
+            sizeof(CalfTubeClass),
+            NULL, /* base_init */
+            NULL, /* base_finalize */
+            (GClassInitFunc)calf_tube_class_init,
+            NULL, /* class_finalize */
+            NULL, /* class_data */
+            sizeof(CalfTube),
+            0,    /* n_preallocs */
+            (GInstanceInitFunc)calf_tube_init
+        };
+        
+        for (int i = 0; ; i++) {
+            char *name = g_strdup_printf("CalfTube%u%d", 
+                ((unsigned int)(intptr_t)calf_tube_class_init) >> 16, i);
+            if (g_type_from_name(name)) {
+                free(name);
+                continue;
+            }
+            type = g_type_register_static( GTK_TYPE_DRAWING_AREA,
+                                           name,
+                                           &type_info,
+                                           (GTypeFlags)0);
+            free(name);
+            break;
+        }
+    }
+    return type;
+}
diff --git a/src/gui.cpp b/src/gui.cpp
index a2748e7..5474a3d 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -187,6 +187,8 @@ param_control *plugin_gui::create_control_from_xml(const char *element, const ch
         return new curve_param_control;
     if (!strcmp(element, "led"))
         return new led_param_control;
+    if (!strcmp(element, "tube"))
+        return new tube_param_control;
     if (!strcmp(element, "entry"))
         return new entry_param_control;
     if (!strcmp(element, "filechooser"))
diff --git a/src/gui_controls.cpp b/src/gui_controls.cpp
index e102297..7c8896e 100644
--- a/src/gui_controls.cpp
+++ b/src/gui_controls.cpp
@@ -347,6 +347,28 @@ void led_param_control::set()
         update_label();
 }
 
+// tube
+
+GtkWidget *tube_param_control::create(plugin_gui *_gui, int _param_no)
+{
+    gui = _gui, param_no = _param_no;
+    // parameter_properties &props = get_props();
+    widget = calf_tube_new ();
+    gtk_widget_set_name(GTK_WIDGET(widget), "calf-tube");
+    CALF_TUBE(widget)->size = get_int("size", 2);
+    CALF_TUBE(widget)->direction = get_int("direction", 2);
+    return widget;
+}
+
+void tube_param_control::set()
+{
+    _GUARD_CHANGE_
+    // parameter_properties &props = get_props();
+    calf_tube_set_value (CALF_TUBE (widget), gui->plugin->get_param_value(param_no));
+    if (label)
+        update_label();
+}
+
 // check box
 
 GtkWidget *check_param_control::create(plugin_gui *_gui, int _param_no)
diff --git a/src/modules.cpp b/src/modules.cpp
index 5f90f8f..bf945c7 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -388,13 +388,13 @@ CALF_PORT_PROPS(deesser) = {
     { 0,      0,  1,    0, PF_BOOL | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_out", "Out" },
     { 0,      0,  1,    0, PF_ENUM | PF_CTL_COMBO, deesser_detection_names, "detection", "Detection" },
     { 0,      0,  1,    0, PF_ENUM | PF_CTL_COMBO, deesser_mode_names, "mode", "Mode" },
-    { 0.0625, 0.000976563, 1,    0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "threshold", "Threshold" },
-    { 5,      1, 20,  21, PF_FLOAT | PF_SCALE_LOG_INF | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "ratio", "Ratio" },
+    { 0.125,  0.000976563, 1,    0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "threshold", "Threshold" },
+    { 3,      1, 20,  21, PF_FLOAT | PF_SCALE_LOG_INF | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "ratio", "Ratio" },
     { 15,     1, 100,   1, PF_INT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "laxity", "Laxity" },
     { 1,      1, 64,    0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "makeup", "Makeup" },
 
-    { 5000,   10,   18000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "f1_freq", "Split" },
-    { 6000,   10,   18000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "f2_freq", "Peak" },
+    { 6000,   10,   18000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "f1_freq", "Split" },
+    { 4500,   10,   18000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "f2_freq", "Peak" },
     { 1,      0.0625,  16, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "f1_level", "Gain" },
     { 4,      0.0625,  16, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "f2_level", "Level" },
     { 1,      0.1,     100,1, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "f2_q", "Peak Q" },
diff --git a/src/modules_dsp.cpp b/src/modules_dsp.cpp
index 22bbc57..66524da 100644
--- a/src/modules_dsp.cpp
+++ b/src/modules_dsp.cpp
@@ -1490,6 +1490,7 @@ uint32_t deesser_audio_module::process(uint32_t offset, uint32_t numsamples, uin
         // process
         
         detected_led -= std::min(detected_led,  numsamples);
+        clip_led   -= std::min(clip_led,  numsamples);
         
         while(offset < numsamples) {
             // cycle through samples
@@ -1503,6 +1504,8 @@ uint32_t deesser_audio_module::process(uint32_t offset, uint32_t numsamples, uin
             float rightAC = inR;
             float leftSC = inL;
             float rightSC = inR;
+            float leftRC = inL;
+            float rightRC = inR;
             float leftMC = inL;
             float rightMC = inR;
             
@@ -1517,11 +1520,15 @@ uint32_t deesser_audio_module::process(uint32_t offset, uint32_t numsamples, uin
                     compressor.process(leftAC, rightAC, leftSC, rightSC);
                     break;
                 case SPLIT:
-                    compressor.process(leftSC, rightSC, leftSC, rightSC);
+                    hpL.sanitize();
+                    hpR.sanitize();
+                    leftRC = hpL.process(leftRC);
+                    rightRC = hpR.process(rightRC);
+                    compressor.process(leftRC, rightRC, leftSC, rightSC);
                     leftAC = lpL.process(leftAC);
                     rightAC = lpR.process(rightAC);
-                    leftAC += leftSC;
-                    rightAC += rightSC;
+                    leftAC += leftRC;
+                    rightAC += rightRC;
                     break;
             }
             
@@ -1540,7 +1547,14 @@ uint32_t deesser_audio_module::process(uint32_t offset, uint32_t numsamples, uin
             if(std::max(fabs(leftSC), fabs(rightSC)) > 0.1) {
                 detected_led   = srate >> 3;
             }
-            clip_out = std::max(fabs(outL), fabs(outR));
+            if(std::max(fabs(leftAC), fabs(rightAC)) > 1.f) {
+                clip_led   = srate >> 3;
+            }
+            if(clip_led > 0) {
+                clip_out = 1.f;
+            } else {
+                clip_out = std::max(fabs(outL), fabs(outR));
+            }
             detected = std::max(fabs(leftMC), fabs(rightMC));
             
             // next sample

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list