[SCM] calf/master: show phase by freq in analyzer

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


The following commit has been merged in the master branch:
commit 36dea348ad3d40ac944591af28edab9b142bffbd
Author: Christian Holschuh <chrisch.holli at gmx.de>
Date:   Tue Mar 6 02:48:03 2012 +0100

    show phase by freq in analyzer

diff --git a/src/calf/modules.h b/src/calf/modules.h
index 9a53768..91b8035 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -351,6 +351,7 @@ protected:
     mutable int ____analyzer_phase_was_drawn_here;
     mutable int ____analyzer_smooth_dirty;
     mutable int ____analyzer_hold_dirty;
+    mutable int ____analyzer_sanitize;
 
 };
 
diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index df71a8c..b76572b 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -125,9 +125,9 @@ calf_line_graph_draw_graph( cairo_t *c, float *data, int sx, int sy, int mode )
         }
     }
     if(!mode) {
-        cairo_fill(c);
-    } else {
         cairo_stroke(c);
+    } else {
+        cairo_fill(c);
     }
 }
 
diff --git a/src/modules.cpp b/src/modules.cpp
index 507c80d..6d4b3d8 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -882,10 +882,11 @@ analyzer_audio_module::analyzer_audio_module() {
     memset(fft_hold, 0, max_fft_cache_size * sizeof(float)); // reset buffer to zero
     fft_freeze = (float*) calloc(max_fft_cache_size, sizeof(float));
     memset(fft_freeze, 0, max_fft_cache_size * sizeof(float)); // reset buffer to zero
-    
+    fft_plan = false;
     ____analyzer_phase_was_drawn_here = 0;
     ____analyzer_smooth_dirty = 0;
     ____analyzer_hold_dirty = 0;
+    ____analyzer_sanitize = 0;
 
 }
 
@@ -899,6 +900,7 @@ void analyzer_audio_module::deactivate() {
 
 void analyzer_audio_module::params_changed() {
     if(*params[param_analyzer_accuracy] != _acc_old) {
+        ____analyzer_sanitize = 1;
         _accuracy = pow(2, 7 + *params[param_analyzer_accuracy]);
         _acc_old = *params[param_analyzer_accuracy];
         // recreate fftw plan
@@ -983,11 +985,18 @@ bool analyzer_audio_module::get_phase_graph(float ** _buffer, int *_length, int
 
 bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context, int *mode) const
 {
+    if(____analyzer_sanitize) {
+        memset(fft_in, 1e-20, max_fft_cache_size * sizeof(float)); // reset buffer to zero
+        memset(fft_inL, 1e-20, max_fft_cache_size * sizeof(float));
+        memset(fft_inR, 1e-20, max_fft_cache_size * sizeof(float));
+        ____analyzer_sanitize = 0;
+        return false;
+    }
+    
     if (!active or subindex > 1 or !*params[param_analyzer_display]
         or (subindex > 0 and !*params[param_analyzer_hold]))
         // stop drawing
         return false;
-
     bool fftdone = false; // if fft was renewed, this one is true
     double freq;
     int iter = 0;
@@ -1062,7 +1071,7 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
             // non-normalized
             rfftw_one(fft_plan, fft_in, fft_out);
             //run fft for left and right channel while in "phase by freq" mode
-            if(*params[param_analyzer_correction] == 3) {
+            if(*params[param_analyzer_correction] == 3 ) {
                 rfftw_one(fft_plan, fft_inL, fft_outL);
                 rfftw_one(fft_plan, fft_inR, fft_outR);
             }
@@ -1080,8 +1089,7 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
     }
     for (int i = 0; i <= points; i++)
     {
-        float lastoutL = 0.f;
-        float lastoutR = 0.f;
+        float lastout = 0.f;
         // cycle through the points to draw
         freq = 20.f * pow (1000.f, (float)i / points); //1000=20000/1000
         if(*params[param_analyzer_linear]) {
@@ -1097,7 +1105,6 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
             if(fftdone and i) {
                 int n = 0;
                 float var1 = 0.f;
-                float var2 = 0.f;
                 
                 switch((int)*params[param_analyzer_correction]) {
                     case 0:
@@ -1119,11 +1126,11 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
                                 n++;
                             }
                             if(k != 0) var1 += fabs(fft_out[_iter + k]);
-                            else if(i) var1 += fabs(lastoutL);
+                            else if(i) var1 += fabs(lastout);
                             else var1 += fabs(fft_out[_iter]);
                             n++;
                         }
-                        lastoutL = fft_out[_iter];
+                        lastout = fft_out[_iter];
                         fft_out[_iter] = std::max(n * fabs(fft_out[_iter]) - var1 , 1e-20);
                     break;
                     case 3:
@@ -1138,6 +1145,7 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
                         float diff_fft;
                         diff_fft = fabs(fft_outL[_iter]) - fabs(fft_outR[_iter]);
                         fft_out[_iter] = diff_fft / _accuracy;
+                        //printf("fft_out[_iter]: %.4f\n",fft_out[_iter]);
                     break;
                  }
             }
@@ -1177,16 +1185,15 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
             }
             data[i] = dB_grid(fabs(val) / _accuracy * 2.f);
             if(*params[param_analyzer_correction] == 3) {
-                if(i)data[i] = fft_out[iter];
-                if(!i)data[i}
-                if(fabs(data[i])>1.f) printf("mehr als 1!!!!!!!!!! bei %5d bei iter %4d und _iter %4d\n",i,iter,_iter);
+                if(i) data[i] = fft_out[iter];
+                else data[i] = 0.f;
+//                if(fabs(data[i])>1.f) printf("mehr als 1 bei %5d bei %4d : %.4f\n",i,iter,data[i]);
             } 
-        } //else if(*params[param_analyzer_correction] == 2) {
-          //  data[i] = dB_grid(fabs(1e-20) / _accuracy * 2.f);
-          //  } 
+        }
         else {
             data[i] = INFINITY;
         }
+        printf("data: %.5f\n", data[i]);
     }
     ____analyzer_smooth_dirty = 0;
     if(subindex == 1) {
@@ -1208,6 +1215,7 @@ bool analyzer_audio_module::get_graph(int index, int subindex, float *data, int
         // draw lines
         *mode = 0;
     }
+    ____analyzer_sanitize = 0;
     return true;
 }
 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list