[SCM] calf/master: Use mode in line-graph instead of bars and boxes

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:40:56 UTC 2013


The following commit has been merged in the master branch:
commit 2868f7ae53d77cca671f6fe2480719e3bebf7680
Author: Markus Schmidt <schmidt at boomshop.net>
Date:   Tue Mar 6 02:26:19 2012 +0100

    Use mode in line-graph instead of bars and boxes

diff --git a/gui/gui-analyzer.xml b/gui/gui-analyzer.xml
index aaf4caa..93d50d2 100644
--- a/gui/gui-analyzer.xml
+++ b/gui/gui-analyzer.xml
@@ -19,7 +19,7 @@
                             <combo param="analyzer_smoothing" expand="0" fill="0"/>
                             <combo param="analyzer_correction" expand="0" fill="0"/>
                         </hbox>
-                        <line-graph refresh="1" width="560" height="240" param="analyzer_level" expand="1" fill="1" use_fade="1" fade="0.6" bars="1"/>
+                        <line-graph refresh="1" width="560" height="240" param="analyzer_level" expand="1" fill="1" use_fade="1" fade="0.6"/>
                         <hbox>
                             <hbox expand="1" fill="1"></hbox>
                             <hbox expand="0" fill="0" spacing="12">
diff --git a/src/calf/custom_ctl.h b/src/calf/custom_ctl.h
index c5c2405..4ba736c 100644
--- a/src/calf/custom_ctl.h
+++ b/src/calf/custom_ctl.h
@@ -47,8 +47,7 @@ struct CalfLineGraph
     bool is_square;
     bool use_fade;
     float fade;
-    bool bars;
-    bool boxes;
+    int mode;
     cairo_surface_t *cache_surface;
     cairo_surface_t *fade_surface;
     //GdkPixmap *cache_pixmap;
diff --git a/src/calf/giface.h b/src/calf/giface.h
index adfe47f..1acdefc 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -164,7 +164,7 @@ struct line_graph_iface
     /// @param context cairo context to adjust (for multicolour graphs etc.)
     /// @retval true graph data was returned; subindex+1 graph may or may not be available
     /// @retval false graph data was not returned; subindex+1 graph does not exist either
-    virtual bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context, bool *bars, bool *blocks) const { return false; }
+    virtual bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context, int *mode) const { return false; }
 
     /// Obtain subindex'th dot of parameter 'index'
     /// @param index parameter/dot number (usually tied to particular plugin control port)
diff --git a/src/calf/modules.h b/src/calf/modules.h
index b5d0f75..9a53768 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -320,7 +320,7 @@ public:
     void deactivate();
     uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
     bool get_phase_graph(float ** _buffer, int * _length, int * _mode, bool * _use_fade, float * _fade, int * _accuracy, bool * _display) const;
-    bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context, bool *bars, bool *boxes) const;
+    bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context, int *mode) const;
     
 
 protected:
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index 51a01cd..df71a8c 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -76,7 +76,7 @@ calf_line_graph_draw_grid( cairo_t *c, std::string &legend, bool vertical, float
 }
 
 static void
-calf_line_graph_draw_graph( cairo_t *c, float *data, int sx, int sy, bool bars, bool boxes )
+calf_line_graph_draw_graph( cairo_t *c, float *data, int sx, int sy, int mode )
 {
     int ox=5, oy=5;
     int _last = 0;
@@ -84,31 +84,47 @@ calf_line_graph_draw_graph( cairo_t *c, float *data, int sx, int sy, bool bars,
     for (int i = 0; i < sx; i++)
     {
         y = (int)(oy + sy / 2 - (sy / 2 - 1) * data[i]);
-        if(bars) {
-            // we want to draw bars
-            if(!i) {
-                _last = 0;
-            } else if (i and ((data[i] < INFINITY) or i == sx - 1)) {
-                if(boxes)
-                    cairo_rectangle(c, ox + _last, oy + y, i - _last, 3);
+        switch(mode) {
+            case 0:
+                // we want to draw a line
+                if (i and (data[i] < INFINITY or i == sx - 1)) {
+                    cairo_line_to(c, ox + i, y);
+                } else if (i) {
+                    continue;
+                }
                 else
+                    cairo_move_to(c, ox, y);
+                break;
+            case 1:
+                // bars are used
+                if (i and ((data[i] < INFINITY) or i == sx - 1)) {
                     cairo_rectangle(c, ox + _last, oy + y, i - _last, sy - y);
-                _last = i;
-            } else {
-                continue;
-            }
-        } else {
-            // we want to draw a line
-            if (i and (data[i] < INFINITY or i == sx - 1)) {
-                cairo_line_to(c, ox + i, y);
-            } else if (i) {
-                continue;
-            }
-            else
-                cairo_move_to(c, ox, y);
+                    _last = i;
+                } else {
+                    continue;
+                }
+                break;
+            case 2:
+                // this one is drawing little boxes at the values position
+                if (i and ((data[i] < INFINITY) or i == sx - 1)) {
+                    cairo_rectangle(c, ox + _last, oy + y, i - _last, 3);
+                    _last = i;
+                } else {
+                    continue;
+                }
+                break;
+            case 3:
+                // this one is drawing bars centered on the y axis
+                if (i and ((data[i] < INFINITY) or i == sx - 1)) {
+                    cairo_rectangle(c, ox + _last, oy + y, i - _last, 3);
+                    _last = i;
+                } else {
+                    continue;
+                }
+                break;
         }
     }
-    if(bars) {
+    if(!mode) {
         cairo_fill(c);
     } else {
         cairo_stroke(c);
@@ -245,9 +261,9 @@ calf_line_graph_expose (GtkWidget *widget, GdkEventExpose *event)
             cairo_set_source_rgba(cache_cr, 0.15, 0.2, 0.0, 0.5);
             cairo_set_line_join(cache_cr, CAIRO_LINE_JOIN_MITER);
             cairo_set_line_width(cache_cr, 1);
-            for(graph_n = 0; (graph_n<cache_graph_index) && lg->source->get_graph(lg->source_id, graph_n, data, sx, &cache_cimpl, &lg->bars, &lg->boxes); graph_n++)
+            for(graph_n = 0; (graph_n<cache_graph_index) && lg->source->get_graph(lg->source_id, graph_n, data, sx, &cache_cimpl, &lg->mode); graph_n++)
             {
-                calf_line_graph_draw_graph( cache_cr, data, sx, sy, lg->bars, lg->boxes and graph_n );
+                calf_line_graph_draw_graph( cache_cr, data, sx, sy, lg->mode );
             }
             gdk_cairo_set_source_color(cache_cr, &sc3);
             for(dot_n = 0; (dot_n<cache_dot_index) && lg->source->get_dot(lg->source_id, dot_n, x, y, size = 3, &cache_cimpl); dot_n++)
@@ -290,9 +306,9 @@ calf_line_graph_expose (GtkWidget *widget, GdkEventExpose *event)
         cairo_set_source_rgba(cache_cr, 0.15, 0.2, 0.0, 0.5);
         cairo_set_line_join(cache_cr, CAIRO_LINE_JOIN_MITER);
         cairo_set_line_width(cache_cr, 1);
-        for(int gn = graph_n; lg->source->get_graph(lg->source_id, gn, data, sx, &cache_cimpl, &lg->bars, &lg->boxes); gn++)
+        for(int gn = graph_n; lg->source->get_graph(lg->source_id, gn, data, sx, &cache_cimpl, &lg->mode); gn++)
         {
-            calf_line_graph_draw_graph( cache_cr, data, sx, sy, lg->bars, lg->boxes and gn );
+            calf_line_graph_draw_graph( cache_cr, data, sx, sy, lg->mode );
         }
         gdk_cairo_set_source_color(cache_cr, &sc3);
         for(int gn = dot_n; lg->source->get_dot(lg->source_id, gn, x, y, size = 3, &cache_cimpl); gn++)
diff --git a/src/gui_controls.cpp b/src/gui_controls.cpp
index e309435..8e704f6 100644
--- a/src/gui_controls.cpp
+++ b/src/gui_controls.cpp
@@ -919,8 +919,7 @@ GtkWidget *line_graph_param_control::create(plugin_gui *_gui, int _param_no)
     clg->source_id = param_no;
     CALF_LINE_GRAPH(widget)->use_fade = get_int("use_fade", 0);
     CALF_LINE_GRAPH(widget)->fade = get_float("fade", 0.5);
-    CALF_LINE_GRAPH(widget)->bars = get_int("bars", 0);
-    CALF_LINE_GRAPH(widget)->boxes = get_int("boxes", 0);
+    CALF_LINE_GRAPH(widget)->mode = get_int("mode", 0);
     gtk_widget_set_name(GTK_WIDGET(widget), "Calf-LineGraph");
     return widget;
 }
diff --git a/src/modules.cpp b/src/modules.cpp
index 41e0775..09454bc 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -981,25 +981,19 @@ bool analyzer_audio_module::get_phase_graph(float ** _buffer, int *_length, int
     return false;
 }
 
-bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context, bool *bars, bool *boxes) const
+bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context, int *mode) const
 {
     if (!active or subindex > 1 or !*params[param_analyzer_display]
         or (subindex > 0 and !*params[param_analyzer_hold]))
         // stop drawing
         return false;
 
-    if(*params[param_analyzer_bars])
-        *bars = true;
-    else
-        *bars = false;
-    
     bool fftdone = false; // if fft was renewed, this one is true
     double freq;
     int iter = 0;
     int _iter = 0;
     int _param_speed = 16 - (int)*params[param_analyzer_speed];
     if(subindex == 0) {
-        
         if(!((int)____analyzer_phase_was_drawn_here % _param_speed)) {
             // seems we have to do a fft, so let's read the latest data from the
             // buffer to send it to fft
@@ -1083,7 +1077,7 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
         // accuracy was changed so we have to recalc linear transition
         int _lintrans = (int)((float)points * log((20.f + (float)srate / (float)_accuracy) / 20.f) / log(1000.f));  
         lintrans = (int)(_lintrans + points % _lintrans / floor(points / _lintrans));
-    } 
+    }
     for (int i = 0; i <= points; i++)
     {
         float lastoutL = 0.f;
@@ -1164,13 +1158,11 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
             }
             iter = _iter;
             float val = 0.f;
-            *boxes = false;
             if (*params[param_analyzer_freeze]) {
                 // freeze enabled
                 val = fft_freeze[iter];
             } else if (subindex == 1) {
                 // we draw the hold buffer
-                *boxes = true;
                 val = fft_hold[iter];
             } else {
                 // we draw normally (no freeze)
@@ -1211,6 +1203,21 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
         // subtle hold line
         context->set_source_rgba(0.35, 0.4, 0.2, 0.2);
     }
+    if(*params[param_analyzer_bars]) {
+        if(subindex == 0) {
+            // draw bars
+            *mode = 1;
+        } else {
+            // draw boxes
+            *mode = 2;
+        }
+    } else if (*params[param_analyzer_correction] == 3) {
+        // draw centered bars
+        *mode = 3;
+    } else {
+        // draw lines
+        *mode = 0;
+    }
     return true;
 }
 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list