[xiph-commits] r18234 - trunk/spectrum

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Fri Apr 13 11:49:09 PDT 2012


Author: xiphmont
Date: 2012-04-13 11:49:09 -0700 (Fri, 13 Apr 2012)
New Revision: 18234

Modified:
   trunk/spectrum/version.h
   trunk/spectrum/wave_panel.c
   trunk/spectrum/wave_plot.c
   trunk/spectrum/wave_process.c
   trunk/spectrum/waveform.h
Log:
Fix line cap behavior
implement logarithmic Y scales



Modified: trunk/spectrum/version.h
===================================================================
--- trunk/spectrum/version.h	2012-04-13 08:51:06 UTC (rev 18233)
+++ trunk/spectrum/version.h	2012-04-13 18:49:09 UTC (rev 18234)
@@ -1,2 +1,2 @@
 #define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Fri Apr 13 04:45:36 EDT 2012] */
+/* DO NOT EDIT: Automated versioning hack [Fri Apr 13 14:48:15 EDT 2012] */

Modified: trunk/spectrum/wave_panel.c
===================================================================
--- trunk/spectrum/wave_panel.c	2012-04-13 08:51:06 UTC (rev 18233)
+++ trunk/spectrum/wave_panel.c	2012-04-13 18:49:09 UTC (rev 18234)
@@ -67,8 +67,10 @@
 static void set_slices(int interval, int span){
 
   /* update interval limited to < 25fps */
-  int temp = (interval < 50000 ? 50000:interval),fi;
+  //int temp = (interval < 50000 ? 50000:interval),fi;
 
+  int temp=interval,fi;
+
   pthread_mutex_lock(&ioparam_mutex);
   if(temp <= span){
     /* if the fps-limited update interval is shorter than or equal to

Modified: trunk/spectrum/wave_plot.c
===================================================================
--- trunk/spectrum/wave_plot.c	2012-04-13 08:51:06 UTC (rev 18233)
+++ trunk/spectrum/wave_plot.c	2012-04-13 18:49:09 UTC (rev 18234)
@@ -107,7 +107,7 @@
     gdk_gc_copy(p->drawgc,widget->style->black_gc);
     gdk_gc_copy(p->twogc,widget->style->black_gc);
 
-    gdk_gc_set_line_attributes(p->twogc,2,GDK_LINE_SOLID,GDK_CAP_PROJECTING,
+    gdk_gc_set_line_attributes(p->twogc,2,GDK_LINE_SOLID,GDK_CAP_BUTT,
                                GDK_JOIN_MITER);
   }
 
@@ -259,13 +259,13 @@
             float spani = 1000000./p->span/p->rate[fi]*wp;
             int hp=height-p->pady;
             int cp=hp/2;
-            float ym=hp*8./18./p->range;
+            float ym=hp*8./18.;
 
             switch(p->type){
             case 0: /* zero-hold */
               {
                 int x0=-1;
-                float yH=NAN,yL=NAN;
+                float yH=NAN,yL=NAN,y0=NAN;
                 int acc=0;
                 for(k=0;k<spann;k++){
                   int x1 = rint(k*spani);
@@ -277,15 +277,14 @@
                         gdk_draw_line(p->backing,p->twogc,
                                       x0+padx,rint(yL)+cp,x0+padx,
                                       rint(yH)+cp);
-                    }else{
-                      if(!isnan(yL)){
-                        gdk_draw_line(p->backing,p->twogc,
-                                      x0+padx,rint(yL)+cp,x1+padx,rint(yL)+cp);
+                    }
+                    if(!isnan(y0)){
+                      gdk_draw_line(p->backing,p->twogc,
+                                    x0+padx-1,rint(y0)+cp,x1+padx+1,rint(y0)+cp);
 
-                        if(!isnan(yH))
-                          gdk_draw_line(p->backing,p->twogc,
-                                        x1+padx,rint(yL)+cp,x1+padx,rint(y1)+cp);
-                      }
+                      if(!isnan(y1))
+                        gdk_draw_line(p->backing,p->twogc,
+                                      x1+padx,rint(y0)+cp,x1+padx,rint(y1)+cp);
                     }
 
                     acc=1;
@@ -298,6 +297,7 @@
                     }
                   }
                   x0=x1;
+                  y0=y1;
                 }
                 {
                   int x1 = rint(k*spani);
@@ -306,56 +306,51 @@
                     if(!isnan(yL)&&!isnan(yH))
                       gdk_draw_line(p->backing,p->twogc,
                                     x0+padx,rint(yL)+cp,x0+padx,rint(yH)+cp);
-                  }else{
-                    if(!isnan(yL)){
-                      gdk_draw_line(p->backing,p->twogc,
-                                    x0+padx,rint(yL)+cp,x1+padx,rint(yL)+cp);
-                    }
                   }
                 }
               }
               break;
             case 1: /* linear interpolation */
               {
-                int x0=-1,x1=-1,x2;
-                float y0=NAN,y1a=NAN,y1b=NAN,y1;
+                int x0=-1;
+                float yH=NAN,yL=NAN,y0=NAN;
+                int acc=0;
+                for(k=0;k<spann;k++){
+                  int x1 = rint(k*spani);
+                  float y1 = data[k]*ym;
 
-                for(k=1;k<spann;k++){
-                  x2 = rint((k+1)*spani);
-                  y1 = data[k]*ym;
-                  if(x0<x1){
-                    if(!isnan(y1) && !isnan(y0))
+                  if(x1>x0){
+                    if(acc>1){
+                      if(!isnan(yL) && !isnan(yH))
+                        gdk_draw_line(p->backing,p->twogc,
+                                      x0+padx,rint(yL)+cp,x0+padx,
+                                      rint(yH)+cp);
+                    }
+                    if(!isnan(y0) && !isnan(y1)){
                       gdk_draw_line(p->backing,p->twogc,
                                     x0+padx,rint(y0)+cp,x1+padx,rint(y1)+cp);
-                    y1a=y1b=y1;
+                    }
+
+                    acc=1;
+                    yH=yL=y1;
                   }else{
+                    acc++;
                     if(!isnan(y1)){
-                      if(y1<y1a || isnan(y1a))y1a=y1;
-                      if(y1>y1b || isnan(y1b))y1b=y1;
+                      if(y1<yL || isnan(yL))yL=y1;
+                      if(y1>yH || isnan(yH))yH=y1;
                     }
-                    if(x1<x2){
-                      if(!isnan(y1a) && !isnan(y1b))
-                        gdk_draw_line(p->backing,p->twogc,
-                                      x1+padx,rint(y1a)+cp,x1+padx,rint(y1b)+cp);
-                    }
                   }
-                  x0=x1;x1=x2;y0=y1;
+                  x0=x1;
+                  y0=y1;
                 }
+                {
+                  int x1 = rint(k*spani);
 
-                y1 = data[k]*ym;
-                if(x0<x1){
-                  if(!isnan(y1) && !isnan(y0))
-                    gdk_draw_line(p->backing,p->twogc,
-                                  x0+padx,rint(y0)+cp,x1+padx,rint(y1)+cp);
-                  y1a=y1b=y1;
-                }else{
-                  if(!isnan(y1)){
-                    if(y1<y1a || isnan(y1a))y1a=y1;
-                    if(y1>y1b || isnan(y1b))y1b=y1;
+                  if(x1<=x0 || acc>1){
+                    if(!isnan(yL) && !isnan(yH))
+                      gdk_draw_line(p->backing,p->twogc,
+                                    x0+padx,rint(yL)+cp,x0+padx,rint(yH)+cp);
                   }
-                  if(!isnan(y1a) && !isnan(y1b))
-                    gdk_draw_line(p->backing,p->twogc,
-                                  x1+padx,rint(y1a)+cp,x1+padx,rint(y1b)+cp);
                 }
               }
               break;
@@ -369,7 +364,7 @@
                   for(k=0;k<spann;k++){
                     int x1 = rint(k*spani);
                     float y1 = data[k]*ym;
-                  
+
                     if(x1>x0){
                       /* once too dense, the lollipop graph drops back
                          to just lines */
@@ -649,7 +644,7 @@
 
   if(!p->configured)return;
 
-  data = process_fetch(p->blockslice, p->overslice, p->span);
+  data = process_fetch(p->blockslice, p->overslice, p->span,p->scale,p->range);
   p->ydata=data;
 }
 

Modified: trunk/spectrum/wave_process.c
===================================================================
--- trunk/spectrum/wave_process.c	2012-04-13 08:51:06 UTC (rev 18233)
+++ trunk/spectrum/wave_process.c	2012-04-13 18:49:09 UTC (rev 18234)
@@ -80,7 +80,8 @@
   return NULL;
 }
 
-float **process_fetch(int *blockslice,int *overslice,int span){
+float **process_fetch(int *blockslice,int *overslice,int span,
+                      int scale,float range){
   int fi,i,j,k,ch;
 
   init_process();
@@ -102,8 +103,19 @@
       float *plotdatap=plot_data[i];
       for(j=0;j<copies;j++){
         float *data=blockbuffer[i]+offset;
-        for(k=0;k<spann;k++)
-          *(plotdatap++)=data[k];
+        if(scale){
+          float drange=todB(range)-scale;
+          for(k=0;k<spann;k++){
+            if(data[k]<0){
+              *(plotdatap++)=-(todB(data[k])-scale)/drange;
+            }else{
+              *(plotdatap++)=(todB(data[k])-scale)/drange;
+            }
+          }
+        }else{
+          for(k=0;k<spann;k++)
+            *(plotdatap++)=(data[k]/range);
+        }
         offset-=overslice[fi];
       }
     }

Modified: trunk/spectrum/waveform.h
===================================================================
--- trunk/spectrum/waveform.h	2012-04-13 08:51:06 UTC (rev 18233)
+++ trunk/spectrum/waveform.h	2012-04-13 18:49:09 UTC (rev 18234)
@@ -81,7 +81,7 @@
 
 extern void panel_go(int argc,char *argv[]);
 extern void *process_thread(void *dummy);
-extern float **process_fetch(int *, int *, int);
+extern float **process_fetch(int *, int *, int, int, float);
 
 extern pthread_mutex_t feedback_mutex;
 extern int feedback_increment;



More information about the commits mailing list