[SCM] calf/master: + GUI: add legend to dB grids

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:38:30 UTC 2013


The following commit has been merged in the master branch:
commit 78b91b91f764d6e85ab18b36e520b72f26ee067c
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Sun Nov 16 20:17:04 2008 +0000

    + GUI: add legend to dB grids

diff --git a/src/calf/giface.h b/src/calf/giface.h
index 91d8497..9394c01 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -163,7 +163,7 @@ struct line_graph_iface
     /// Obtain subindex'th dot of parameter 'index'
     /// @param index parameter/dot number (usually tied to particular plugin control port)
     /// @param subindex dot number (there may be multiple dots graphs for one parameter)
-    virtual bool get_gridline(int index, int subindex, float &pos, bool &vertical, cairo_iface *context) { return false; }
+    virtual bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context) { return false; }
     
     /// Obtain subindex'th static graph of parameter index (static graphs are only dependent on parameter value, not plugin state)
     /// @param index parameter/graph number (usually tied to particular plugin control port)
diff --git a/src/calf/modules.h b/src/calf/modules.h
index f78222d..8781d42 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -129,7 +129,7 @@ public:
         return outputs_mask; // XXXKF allow some delay after input going blank
     }
     bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context);
-    bool get_gridline(int index, int subindex, float &pos, bool &vertical, cairo_iface *context);
+    bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
     float freq_gain(int subindex, float freq, float srate);
 };
 
@@ -366,7 +366,7 @@ public:
     }
     bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context);
     float freq_gain(int subindex, float freq, float srate);
-    bool get_gridline(int index, int subindex, float &pos, bool &vertical, cairo_iface *context);
+    bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
 };
 
 class vintage_delay_audio_module: public audio_module<vintage_delay_metadata>
@@ -689,7 +689,7 @@ public:
     bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context);
     float freq_gain(int subindex, float freq, float srate);
     bool get_dot(int index, int subindex, float &x, float &y, int &size, cairo_iface *context);
-    bool get_gridline(int index, int subindex, float &pos, bool &vertical, cairo_iface *context);
+    bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
 };
 
 extern std::string get_builtin_modules_rdf();
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index 5e4a42c..55dc3c5 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -62,26 +62,44 @@ calf_line_graph_expose (GtkWidget *widget, GdkEventExpose *event)
     cairo_fill(c);
     cairo_impl cimpl;
     cimpl.context = c;
+    cairo_select_font_face(c, "Bitstream Vera Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+    cairo_set_font_size(c, 9);
 
     if (lg->source) {
         float pos = 0;
         bool vertical = false;
         cairo_set_line_width(c, 1);
-        for(int gn = 0; cairo_set_source_rgba(c, 1, 1, 1, 0.5), lg->source->get_gridline(lg->source_id, gn, pos, vertical, &cimpl); gn++)
+        std::string legend;
+        for(int gn = 0; legend = std::string(), cairo_set_source_rgba(c, 1, 1, 1, 0.5), lg->source->get_gridline(lg->source_id, gn, pos, vertical, legend, &cimpl); gn++)
         {
+            cairo_text_extents_t tx;
+            if (!legend.empty())
+                cairo_text_extents(c, legend.c_str(), &tx);
             if (vertical)
             {
                 float x = floor(ox + pos * sx) + 0.5;
                 cairo_move_to(c, x, oy);
                 cairo_line_to(c, x, oy + sy);
+                cairo_stroke(c);
+                if (!legend.empty()) {
+                    
+                    cairo_set_source_rgba(c, 1.0, 1.0, 1.0, 0.75);
+                    cairo_move_to(c, x + 2, oy);
+                    cairo_show_text(c, legend.c_str());
+                }
             }
             else
             {
                 float y = floor(oy + sy / 2 - (sy / 2 - 1) * pos) + 0.5;
                 cairo_move_to(c, ox, y);
                 cairo_line_to(c, ox + sx, y);
+                cairo_stroke(c);
+                if (!legend.empty()) {
+                    cairo_set_source_rgba(c, 1.0, 1.0, 1.0, 0.75);
+                    cairo_move_to(c, ox + 2, y + tx.height/2);
+                    cairo_show_text(c, legend.c_str());
+                }
             }
-            cairo_stroke(c);
         }
         float *data = new float[2 * sx];
         GdkColor sc2 = { 0, 0, 65535, 0 };
diff --git a/src/modules.cpp b/src/modules.cpp
index 5f68f3e..065a080 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -87,11 +87,11 @@ CALF_PORT_NAMES(filter) = {"In L", "In R", "Out L", "Out R"};
 
 const char *filter_choices[] = {
     "12dB/oct Lowpass",
-    "24dB/oct Lowpass",
-    "36dB/oct Lowpass",
+    "24dB/oct Lowpass (2xRes)",
+    "36dB/oct Lowpass (3xRes)",
     "12dB/oct Highpass",
-    "24dB/oct Highpass",
-    "36dB/oct Highpass",
+    "24dB/oct Highpass (2xRes)",
+    "36dB/oct Highpass (3xRes)",
 };
 
 CALF_PORT_PROPS(filter) = {
diff --git a/src/modules_dsp.cpp b/src/modules_dsp.cpp
index 96d9fcb..c4381d4 100644
--- a/src/modules_dsp.cpp
+++ b/src/modules_dsp.cpp
@@ -38,14 +38,20 @@ static void set_channel_color(cairo_iface *context, int channel)
         context->set_source_rgba(0, 1, 0.75);
 }
 
-static bool get_freq_gridline(int subindex, float &pos, bool &vertical, cairo_iface *context)
+static bool get_freq_gridline(int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
 {
     float gain = 16.0 / (1 << subindex);
     pos = log(gain) / log(1024.0) + 0.5;
     if (pos < -1)
         return false;
     if (subindex != 4)
-        context->set_source_rgba(0.25, 0.25, 0.25, 0.5);
+        context->set_source_rgba(0.25, 0.25, 0.25, subindex & 1 ? 0.5 : 0.75);
+    if (!(subindex & 1))
+    {
+        std::stringstream ss;
+        ss << (24 - 6 * subindex) << " dB";
+        legend = ss.str();
+    }
     vertical = false;
     return true;
 }
@@ -87,10 +93,10 @@ float flanger_audio_module::freq_gain(int subindex, float freq, float srate)
     return (subindex ? right : left).freq_gain(freq, srate);                
 }
 
-bool flanger_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, cairo_iface *context)
+bool flanger_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
 {
     if (index == par_delay)
-        return get_freq_gridline(subindex, pos, vertical, context);
+        return get_freq_gridline(subindex, pos, vertical, legend, context);
     return false;
 }
 
@@ -177,10 +183,10 @@ float filter_audio_module::freq_gain(int subindex, float freq, float srate)
     return level;
 }
 
-bool filter_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, cairo_iface *context)
+bool filter_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
 {
     if (index == par_cutoff)
-        return get_freq_gridline(subindex, pos, vertical, context);
+        return get_freq_gridline(subindex, pos, vertical, legend, context);
     return false;
 }
 
@@ -294,7 +300,7 @@ bool multichorus_audio_module::get_dot(int index, int subindex, float &x, float
     return true;
 }
 
-bool multichorus_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, cairo_iface *context)
+bool multichorus_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
 {
     if (index == par_rate && !subindex)
     {
@@ -303,7 +309,7 @@ bool multichorus_audio_module::get_gridline(int index, int subindex, float &pos,
         return true;
     }
     if (index == par_delay)
-        return get_freq_gridline(subindex, pos, vertical, context);
+        return get_freq_gridline(subindex, pos, vertical, legend, context);
     return false;
 }
 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list