[SCM] calf/master: + GUI: graph improvements (?)

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


The following commit has been merged in the master branch:
commit 98d92c6b61b2e7a4bdb5d2a0624f11f53c70fb98
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Wed Nov 19 22:46:07 2008 +0000

    + GUI: graph improvements (?)

diff --git a/src/calf/modules.h b/src/calf/modules.h
index b8bf5fc..3e7f3cb 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -61,18 +61,6 @@ public:
 };
 #endif
 
-template<class Fx>
-bool get_graph(Fx &fx, int subindex, float *data, int points)
-{
-    for (int i = 0; i < points; i++)
-    {
-        typedef std::complex<double> cfloat;
-        double freq = 20.0 * pow (20000.0 / 20.0, i * 1.0 / points);
-        data[i] = log(fx.freq_gain(subindex, freq, fx.srate)) / log(1024.0) + 0.5;
-    }
-    return true;
-}
-
 class flanger_audio_module: public audio_module<flanger_metadata>, public line_graph_iface
 {
 public:
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index b612442..452e109 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -71,34 +71,43 @@ calf_line_graph_expose (GtkWidget *widget, GdkEventExpose *event)
         bool vertical = false;
         cairo_set_line_width(c, 1);
         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++)
+        for(int phase = 1; phase <= 2; phase++)
         {
-            cairo_text_extents_t tx;
-            if (!legend.empty())
-                cairo_text_extents(c, legend.c_str(), &tx);
-            if (vertical)
+            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++)
             {
-                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 - (tx.x_bearing + tx.width / 2.0), oy + sy - 2);
-                    cairo_show_text(c, legend.c_str());
+                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;
+                    if (phase == 1)
+                    {
+                        cairo_move_to(c, x, oy);
+                        cairo_line_to(c, x, oy + sy);
+                        cairo_stroke(c);
+                    }
+                    if (phase == 2 && !legend.empty()) {
+                        
+                        cairo_set_source_rgba(c, 1.0, 1.0, 1.0, 0.75);
+                        cairo_move_to(c, x - (tx.x_bearing + tx.width / 2.0), oy + sy - 2);
+                        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 + sx - 2 - tx.width, y + tx.height/2 - 1);
-                    cairo_show_text(c, legend.c_str());
+                else
+                {
+                    float y = floor(oy + sy / 2 - (sy / 2 - 1) * pos) + 0.5;
+                    if (phase == 1)
+                    {
+                        cairo_move_to(c, ox, y);
+                        cairo_line_to(c, ox + sx, y);
+                        cairo_stroke(c);
+                    }
+                    if (phase == 2 && !legend.empty()) {
+                        cairo_set_source_rgba(c, 1.0, 1.0, 1.0, 0.75);
+                        cairo_move_to(c, ox + sx - 2 - tx.width, y + tx.height/2 - 1);
+                        cairo_show_text(c, legend.c_str());
+                    }
                 }
             }
         }
diff --git a/src/modules_dsp.cpp b/src/modules_dsp.cpp
index 881e3a0..c7f2fea 100644
--- a/src/modules_dsp.cpp
+++ b/src/modules_dsp.cpp
@@ -33,13 +33,25 @@ using namespace calf_plugins;
 /// convert amplitude value to normalized grid-ish value (0dB = 0.5, 30dB = 1.0, -30 dB = 0.0, -60dB = -0.5, -90dB = -1.0)
 static inline float dB_grid(float amp)
 {
-    return log(amp) / log(1024.0) + 0.5;
+    return log(amp) / log(256.0) + 0.4;
+}
+
+template<class Fx>
+static bool get_graph(Fx &fx, int subindex, float *data, int points)
+{
+    for (int i = 0; i < points; i++)
+    {
+        typedef std::complex<double> cfloat;
+        double freq = 20.0 * pow (20000.0 / 20.0, i * 1.0 / points);
+        data[i] = dB_grid(fx.freq_gain(subindex, freq, fx.srate));
+    }
+    return true;
 }
 
 /// convert normalized grid-ish value back to amplitude value
 static inline float dB_grid_inv(float pos)
 {
-    return pow(1024.0, pos - 0.5);
+    return pow(256.0, pos - 0.4);
 }
 
 static void set_channel_color(cairo_iface *context, int channel)
@@ -48,6 +60,7 @@ static void set_channel_color(cairo_iface *context, int channel)
         context->set_source_rgba(0.75, 1, 0);
     else
         context->set_source_rgba(0, 1, 0.75);
+    context->set_line_width(1.5);
 }
 
 static bool get_freq_gridline(int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
@@ -95,7 +108,7 @@ bool flanger_audio_module::get_graph(int index, int subindex, float *data, int p
     if (index == par_delay && subindex < 2) 
     {
         set_channel_color(context, subindex);
-        return calf_plugins::get_graph(*this, subindex, data, points);
+        return ::get_graph(*this, subindex, data, points);
     }
     return false;
 }
@@ -182,8 +195,10 @@ bool filter_audio_module::get_graph(int index, int subindex, float *data, int po
 {
     if (!is_active)
         return false;
-    if (index == par_cutoff && !subindex) 
-        return calf_plugins::get_graph(*this, subindex, data, points);
+    if (index == par_cutoff && !subindex) {
+        context->set_line_width(1.5);
+        return ::get_graph(*this, subindex, data, points);
+    }
     return false;
 }
 
@@ -281,7 +296,7 @@ bool multichorus_audio_module::get_graph(int index, int subindex, float *data, i
     if (index == par_delay && subindex < 2) 
     {
         set_channel_color(context, subindex);
-        return calf_plugins::get_graph(*this, subindex, data, points);
+        return ::get_graph(*this, subindex, data, points);
     }
     if (index == par_rate && !subindex) {
         for (int i = 0; i < points; i++)

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list