[xiph-commits] r18811 - trunk/spectrum

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Sun Feb 24 13:11:08 PST 2013


Author: xiphmont
Date: 2013-02-24 13:11:08 -0800 (Sun, 24 Feb 2013)
New Revision: 18811

Modified:
   trunk/spectrum/spec_panel.c
   trunk/spectrum/spec_plot.c
   trunk/spectrum/spec_process.c
   trunk/spectrum/spectrum.c
   trunk/spectrum/version.h
   trunk/spectrum/wave_panel.c
Log:
Make committed version of spectrum/waveform apps consistent with what appears in the video
Improve robustness of phase normalization
Add oversampled trigger config



Modified: trunk/spectrum/spec_panel.c
===================================================================
--- trunk/spectrum/spec_panel.c	2013-02-24 20:12:42 UTC (rev 18810)
+++ trunk/spectrum/spec_panel.c	2013-02-24 21:11:08 UTC (rev 18811)
@@ -57,18 +57,18 @@
 int plot_ch=0;
 int plot_inputs=0;
 
-int plot_scale=0;
+int plot_scale=2;
 int plot_mode=0;
 int plot_mode_save=0;
 int plot_modes=4;
 int plot_link=0;
 int plot_hold=0;
 int plot_lock_y=0;
-int plot_depth=90;
+int plot_depth=140;
 int plot_noise=0;
 int plot_bwchoice=0;
-int plot_detchoice=0;
-int plot_bold=0;
+int plot_detchoice=1;
+int plot_bold=1;
 
 int no_replot=0;
 
@@ -923,7 +923,7 @@
 
     for(i=0;det_entries[i];i++)
       gtk_combo_box_append_text (GTK_COMBO_BOX (menu), det_entries[i]);
-    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),1);
     gtk_box_pack_start(GTK_BOX(bbox),menu,0,0,0);
     g_signal_connect (G_OBJECT (menu), "changed",
                       G_CALLBACK (detectorchange), NULL);
@@ -936,7 +936,7 @@
                      "140dB","200dB",NULL};
     for(i=0;entries[i];i++)
       gtk_combo_box_append_text (GTK_COMBO_BOX (menu), entries[i]);
-    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),4);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),5);
     gtk_box_pack_start(GTK_BOX(bbox),menu,0,0,0);
     g_signal_connect (G_OBJECT (menu), "changed",
                       G_CALLBACK (depthchange), NULL);

Modified: trunk/spectrum/spec_plot.c
===================================================================
--- trunk/spectrum/spec_plot.c	2013-02-24 20:12:42 UTC (rev 18810)
+++ trunk/spectrum/spec_plot.c	2013-02-24 21:11:08 UTC (rev 18811)
@@ -32,7 +32,7 @@
 static double log_llfreqs[16]={10.,20.,30.,50.,100.,200.,300.,500.,
                               1000.,2000.,3000.,5000.,10000.,
                                20000.,30000.,50000.};
-static double log_tfreqs[37]={5.,6.,7.,8.,9.,20.,30.,40.,50.,60.,70.,80.,90.
+static double log_tfreqs[32]={20.,30.,40.,50.,60.,70.,80.,90.
 			 ,200.,300.,400.,500.,600.,700.,800.,900.,
 			 2000.,3000.,4000.,5000.,6000.,7000.,8000.,9000.,
 			 20000.,30000,40000,50000,60000,70000,80000,90000};
@@ -70,17 +70,17 @@
         if(log_llfreqs[i]<(nyq-.1))
           p->xlgrids=i+1;
       }
-      for(i=0;i<37;i++){
+      for(i=0;i<32;i++){
         if(log_tfreqs[i]<(nyq-.1))
           p->xtics=i+1;
       }
 
       for(i=0;i<p->xgrids;i++)
-        p->xgrid[i]=rint( (log10(log_lfreqs[i])-log10(5.))/(log10(nyq)-log10(5.)) * (width-1))+p->padx;
+        p->xgrid[i]=rint( (log10(log_lfreqs[i])-log10(10.))/(log10(nyq)-log10(10.)) * (width-1))+p->padx;
       for(i=0;i<p->xlgrids;i++)
-        p->xlgrid[i]=rint( (log10(log_llfreqs[i])-log10(5.))/(log10(nyq)-log10(5.)) * (width-1))+p->padx;
+        p->xlgrid[i]=rint( (log10(log_llfreqs[i])-log10(10.))/(log10(nyq)-log10(10.)) * (width-1))+p->padx;
       for(i=0;i<p->xtics;i++)
-        p->xtic[i]=rint( (log10(log_tfreqs[i])-log10(5.))/(log10(nyq)-log10(5.)) * (width-1))+p->padx;
+        p->xtic[i]=rint( (log10(log_tfreqs[i])-log10(10.))/(log10(nyq)-log10(10.)) * (width-1))+p->padx;
 
       break;
     case 1: /* ISO log */

Modified: trunk/spectrum/spec_process.c
===================================================================
--- trunk/spectrum/spec_process.c	2013-02-24 20:12:42 UTC (rev 18810)
+++ trunk/spectrum/spec_process.c	2013-02-24 21:11:08 UTC (rev 18811)
@@ -921,19 +921,51 @@
   return -todB(sum/(x1-x0))*.5;
 }
 
+int valcomp(const void *a, const void *b){
+  if((float *)a<(float*)b)return -1;
+  if((float *)a>(float*)b)return 1;
+  return 0;
+}
+
 float norm_ph(float *dataR, float *dataI,int n,int rate){
-  int i;
+  int i,j;
   int x0 = 100.*blocksize/rate;
-  int x1 = x0+blocksize/4;
-
+  int x1 = 18000.*blocksize/rate;
   float sumR=0.;
   float sumI=0.;
+  int ph_over = (blocksize/2)/64;
+
+  if(x1>blocksize/2)x1=blocksize*7/16;
+
   for(i=x0+1;i<x1;i++){
-    sumR += dataR[i-1]*dataR[i] + dataI[i-1]*dataI[i];
-    sumI += dataR[i-1]*dataI[i] - dataI[i-1]*dataR[i];
+    float R = dataR[i-1]*dataR[i] + dataI[i-1]*dataI[i];
+    float I = dataR[i-1]*dataI[i] - dataI[i-1]*dataR[i];
+    float iM = 1./(hypot(R,I));
+    sumR += R*iM;
+    sumI += I*iM;
   }
 
-  return -atan2f(sumI,sumR);
+  /* determine offset for maximal flatness */
+  float adj = -atan2(sumI,sumR);
+  float unitR = cosf(adj);
+  float unitI = sinf(adj);
+  float valstack[(x1-x0)/ph_over+1];
+  int stackcount=0;
+  for(i=x0;i+ph_over<=x1;i+=ph_over){
+    sumR=0;
+    sumI=0;
+    for(j=0;j<ph_over;j++){
+      float R = unitR*sumR + unitI*sumI + dataR[i+j];
+      float I = unitR*sumI - unitI*sumR + dataI[i+j];
+      sumR = R;
+      sumI = I;
+    }
+    /* the residual phase offset after first-stage correction */
+    float a=aadd(wrap_atan2f(sumI,sumR),adj*(i+j-1));
+    valstack[stackcount++] = a/(i+j-1);
+  }
+  qsort(valstack,stackcount,sizeof(*valstack),valcomp);
+  return adj-valstack[stackcount/2];
 }
 
 /* how many bins to 'trim' off the edge of calculated data when we
@@ -1071,14 +1103,14 @@
 	switch(scale){
 	case 0: /* log */
 	  lfreq= pow(10.,(i-off)/(width-1)
-		     * (log10(nyq)-log10(5.))
-		     + log10(5.)) * loff;
+		     * (log10(nyq)-log10(10.))
+		     + log10(10.)) * loff;
 	  mfreq= pow(10.,((float)i)/(width-1)
-		     * (log10(nyq)-log10(5.))
-		     + log10(5.));
+		     * (log10(nyq)-log10(10.))
+		     + log10(10.));
 	  hfreq= pow(10.,(i+off)/(width-1)
-		     * (log10(nyq)-log10(5.))
-		     + log10(5.)) * hoff;
+		     * (log10(nyq)-log10(10.))
+		     + log10(10.)) * hoff;
 	  break;
 	case 1: /* ISO */
 	  lfreq= pow(2.,(i-off)/(width-1)
@@ -1258,6 +1290,9 @@
                            &fetch_ret.pmin, &fetch_ret.pmax,
                            fi, width, det, norm);
 
+          /* if phase wraps around, set full scale */
+          /* XXX todo */
+
           fetch_ret.phdelay[fi] = norm*blocksize/(2.*M_PI*rate[fi]);
         }
       }

Modified: trunk/spectrum/spectrum.c
===================================================================
--- trunk/spectrum/spectrum.c	2013-02-24 20:12:42 UTC (rev 18810)
+++ trunk/spectrum/spectrum.c	2013-02-24 21:11:08 UTC (rev 18811)
@@ -34,7 +34,7 @@
 char *version;
 char *inputname[MAX_FILES];
 int inputs=0;
-int blocksize = 131072;
+int blocksize = 32768;
 extern int plot_bold;
 
 void handler(int sig){

Modified: trunk/spectrum/version.h
===================================================================
--- trunk/spectrum/version.h	2013-02-24 20:12:42 UTC (rev 18810)
+++ trunk/spectrum/version.h	2013-02-24 21:11:08 UTC (rev 18811)
@@ -1,2 +1,2 @@
 #define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Tue Jul  3 22:17:12 EDT 2012] */
+/* DO NOT EDIT: Automated versioning hack [Tue Feb 19 01:04:07 EST 2013] */

Modified: trunk/spectrum/wave_panel.c
===================================================================
--- trunk/spectrum/wave_panel.c	2013-02-24 20:12:42 UTC (rev 18810)
+++ trunk/spectrum/wave_panel.c	2013-02-24 21:11:08 UTC (rev 18811)
@@ -59,7 +59,7 @@
 int plot_trigger=0;
 int plot_type=0;
 int plot_hold=0;
-int plot_bold=0;
+int plot_bold=1;
 int plot_sep=0;
 
 /* first up... the Fucking Fish */
@@ -526,6 +526,7 @@
   GtkWidget *lefttable=gtk_table_new(4,3,0);
   GtkWidget *plot_control_al;
   GtkWidget *wbold;
+  GtkWidget *triggerbutton;
 
   rightbox=gtk_vbox_new(0,0);
 
@@ -696,13 +697,13 @@
       gtk_combo_box_append_text (GTK_COMBO_BOX (menu), entries[i]);
     g_signal_connect (G_OBJECT (menu), "changed",
 		      G_CALLBACK (spanchange), NULL);
-    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),8);
     gtk_box_pack_start(GTK_BOX(bbox),menu,1,1,0);
   }
 
   /* trigger */
   {
-    GtkWidget *menu=gtk_combo_box_new_text();
+    GtkWidget *menu=triggerbutton=gtk_combo_box_new_text();
     char *entries[]={"free run","0\xE2\x86\x91 trigger","0\xE2\x86\x93 trigger",NULL};
     for(i=0;entries[i];i++)
       gtk_combo_box_append_text (GTK_COMBO_BOX (menu), entries[i]);
@@ -772,6 +773,7 @@
   gtk_key_snooper_install(watch_keyboard,NULL);
 
   gtk_alignment_set_padding(GTK_ALIGNMENT(plot_control_al),0,0,plot_get_left_pad(PLOT(plot)),0);
+  gtk_combo_box_set_active(GTK_COMBO_BOX(triggerbutton),1);
 
 }
 



More information about the commits mailing list