[xiph-commits] r18230 - trunk/spectrum

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Thu Apr 12 23:39:51 PDT 2012


Author: xiphmont
Date: 2012-04-12 23:39:51 -0700 (Thu, 12 Apr 2012)
New Revision: 18230

Modified:
   trunk/spectrum/io.c
   trunk/spectrum/spec_plot.c
   trunk/spectrum/version.h
   trunk/spectrum/wave_panel.c
   trunk/spectrum/wave_plot.c
   trunk/spectrum/wave_plot.h
   trunk/spectrum/wave_process.c
Log:
More fixes/tweaks to the read engine


Modified: trunk/spectrum/io.c
===================================================================
--- trunk/spectrum/io.c	2012-04-12 14:29:17 UTC (rev 18229)
+++ trunk/spectrum/io.c	2012-04-13 06:39:51 UTC (rev 18230)
@@ -392,7 +392,7 @@
 
 /* Convert new data from readbuffer into the blockbuffers until the
    blockbuffer is full */
-static void LBEconvert(void){
+static void LBEconvert(){
   float scale=1./2147483648.;
   int ch=0,fi;
 
@@ -405,6 +405,7 @@
       channels[fi]/bytes*channels[fi]*bytes+readbufferptr[fi];
 
     int bfill = blockbufferfill[fi];
+    int tosize = blocksize + blockslice[fi];
     int rptr = readbufferptr[fi];
     unsigned char *rbuf = readbuffer[fi];
 
@@ -413,7 +414,7 @@
       switch(bytes){
       case 1:
 	
-	while(bfill<blocksize && rptr<readlimit){
+	while(bfill<tosize && rptr<readlimit){
 	  for(j=ch;j<channels[fi]+ch;j++)
 	    blockbuffer[j][bfill]=((rbuf[rptr++]<<24)^xor)*scale;
 	  bfill++;
@@ -423,7 +424,7 @@
       case 2:
       
 	if(bigendian[fi]){
-	  while(bfill<blocksize && rptr<readlimit){
+	  while(bfill<tosize && rptr<readlimit){
 	    for(j=ch;j<channels[fi]+ch;j++){
 	      blockbuffer[j][bfill]=
 		(((rbuf[rptr+1]<<16)| (rbuf[rptr]<<24))^xor)*scale;
@@ -432,7 +433,7 @@
 	    bfill++;
 	  }
 	}else{
-	  while(bfill<blocksize && rptr<readlimit){
+	  while(bfill<tosize && rptr<readlimit){
 	    for(j=ch;j<channels[fi]+ch;j++){
 	      blockbuffer[j][bfill]=
 		(((rbuf[rptr]<<16)| (rbuf[rptr+1]<<24))^xor)*scale;
@@ -446,7 +447,7 @@
       case 3:
 	
 	if(bigendian[fi]){
-	  while(bfill<blocksize && rptr<readlimit){
+	  while(bfill<tosize && rptr<readlimit){
 	    for(j=ch;j<channels[fi]+ch;j++){
 	      blockbuffer[j][bfill]=
 		(((rbuf[rptr+2]<<8)|(rbuf[rptr+1]<<16)|(rbuf[rptr]<<24))^xor)*scale;
@@ -455,7 +456,7 @@
 	    bfill++;
 	  }
 	}else{
-	  while(bfill<blocksize && rptr<readlimit){
+	  while(bfill<tosize && rptr<readlimit){
 	    for(j=ch;j<channels[fi]+ch;j++){
 	      blockbuffer[j][bfill]=
 		(((rbuf[rptr]<<8)|(rbuf[rptr+1]<<16)|(rbuf[rptr+2]<<24))^xor)*scale;
@@ -468,7 +469,7 @@
       case 4:
 	
 	if(bigendian[fi]){
-	  while(bfill<blocksize && rptr<readlimit){
+	  while(bfill<tosize && rptr<readlimit){
 	    for(j=ch;j<channels[fi]+ch;j++){
 	      blockbuffer[j][bfill]=
 		(((rbuf[rptr+3])|(rbuf[rptr+2]<<8)|(rbuf[rptr+1]<<16)|(rbuf[rptr+3]<<24))^xor)*scale;
@@ -477,7 +478,7 @@
 	    bfill++;
 	  }
 	}else{
-	  while(bfill<blocksize && rptr<readlimit){
+	  while(bfill<tosize && rptr<readlimit){
 	    for(j=ch;j<channels[fi]+ch;j++){
 	      blockbuffer[j][bfill]=
 		(((rbuf[rptr])|(rbuf[rptr+1]<<8)|(rbuf[rptr+2]<<16)|(rbuf[rptr+3]<<24))^xor)*scale;
@@ -491,7 +492,7 @@
     }
     ch+=channels[fi];
     blockbufferfill[fi]=bfill;
-    readbufferptr[fi]=rptr;    
+    readbufferptr[fi]=rptr;
   }
 }
 
@@ -510,27 +511,29 @@
 
   if(blockbuffer==0){
     blockbuffer=malloc(total_ch*sizeof(*blockbuffer));
-    
+
     for(i=0;i<total_ch;i++){
-      blockbuffer[i]=calloc(blocksize,sizeof(**blockbuffer));
+      blockbuffer[i]=calloc(blocksize*2,sizeof(**blockbuffer));
     }
   }
 
+  /* if this is first frame, do we allow a single slice or fully
+     fill the buffer */
   for(fi=0;fi<inputs;fi++){
-    /* shift according to slice */
-    if(blockslice[fi]<blocksize)
+    if(blockbufferfill[fi]==0){
       for(i=ch;i<channels[fi]+ch;i++)
-        memmove(blockbuffer[i],blockbuffer[i]+blockslice[fi],
-                (blocksize-blockslice[fi])*sizeof(**blockbuffer));
-    blockbufferfill[fi]-=blockslice[fi];
-    if(blockbufferfill[fi]<0)
-      blockbufferfill[fi]=0;
-    for(i=ch;i<channels[fi]+ch;i++)
-      for(j=blockbufferfill[fi];j<blocksize;j++)
-        blockbuffer[i][j]=NAN;
-    ch+=channels[fi];
+        for(j=0;j<blocksize;j++)
+          blockbuffer[i][j]=NAN;
+      if(partialok){
+        blockbufferfill[fi]=blocksize;
+      }else{
+        blockbufferfill[fi]=blockslice[fi];
+      }
+    }
   }
 
+  /* try to fill buffer to blocksize+slice before performing shift */
+
   while(notdone){
     notdone=0;
 
@@ -539,7 +542,7 @@
 
     ch=0;
     for(fi=0;fi<inputs;fi++){
-      if(blockbufferfill[fi]!=blocksize){
+      if(blockbufferfill[fi]!=blocksize+blockslice[fi]){
 
 	/* shift the read buffer before fill if there's a fractional
 	   frame in it */
@@ -594,6 +597,21 @@
       ch += channels[fi];
     }
   }
+
+  /* shift */
+  for(fi=0,ch=0;fi<inputs;fi++){
+    if(blockbufferfill[fi]>blocksize){
+      for(i=ch;i<channels[fi]+ch;i++)
+        memmove(blockbuffer[i],blockbuffer[i]+(blockbufferfill[fi]-blocksize),
+                blocksize*sizeof(**blockbuffer));
+      blockbufferfill[fi]=blocksize;
+    }
+    for(i=ch;i<channels[fi]+ch;i++)
+      for(j=blockbufferfill[fi];j<blocksize;j++)
+        blockbuffer[i][j]=NAN;
+    ch+=channels[fi];
+  }
+
   return eof;
 }
 

Modified: trunk/spectrum/spec_plot.c
===================================================================
--- trunk/spectrum/spec_plot.c	2012-04-12 14:29:17 UTC (rev 18229)
+++ trunk/spectrum/spec_plot.c	2012-04-13 06:39:51 UTC (rev 18230)
@@ -242,7 +242,7 @@
     gdk_draw_rectangle(p->backing,gc,1,0,height-p->pady,width,p->pady);
 
     gc=parent->style->white_gc;
-    gdk_draw_rectangle(p->backing,gc,1,padx,0,width-padx,height-p->pady+1);
+    gdk_draw_rectangle(p->backing,gc,1,padx,0,width-padx,height-p->pady);
   }
 
   /* draw the noise floor if active */
@@ -541,18 +541,15 @@
 		int ly = y;
 		int lp = prev;
 		
-		if(ly>=height-p->pady)ly=height-p->pady;
-		if(lp>=height-p->pady)lp=height-p->pady;
-		
-		gdk_draw_line(p->backing,p->drawgc,padx+i-1,lp,padx+i,ly);
-		
-		ly++;
-		lp++;
-		
-		if(ly>=height-p->pady)ly=height-p->pady;
-		if(lp>=height-p->pady)lp=height-p->pady;
-		
-		gdk_draw_line(p->backing,p->drawgc,padx+i-1,lp,padx+i,ly);
+		if(lp>=height-p->pady-1)lp=height-p->pady-1;
+
+		if(ly>=height-p->pady-1){
+                  ly=height-p->pady-1;
+                  gdk_draw_line(p->backing,p->drawgc,padx+i-1,lp,padx+i,ly);
+                  gdk_draw_point(p->backing,p->drawgc,padx+i,ly);
+                }else{
+                  gdk_draw_line(p->backing,p->drawgc,padx+i-1,lp,padx+i,ly);
+                }
 	      }
 	      first=1;
 	      prev=y;

Modified: trunk/spectrum/version.h
===================================================================
--- trunk/spectrum/version.h	2012-04-12 14:29:17 UTC (rev 18229)
+++ trunk/spectrum/version.h	2012-04-13 06:39:51 UTC (rev 18230)
@@ -1,2 +1,2 @@
 #define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Thu Apr 12 10:26:00 EDT 2012] */
+/* DO NOT EDIT: Automated versioning hack [Fri Apr 13 02:09:19 EDT 2012] */

Modified: trunk/spectrum/wave_panel.c
===================================================================
--- trunk/spectrum/wave_panel.c	2012-04-12 14:29:17 UTC (rev 18229)
+++ trunk/spectrum/wave_panel.c	2012-04-13 06:39:51 UTC (rev 18230)
@@ -46,10 +46,10 @@
   GtkWidget *plot;
   GtkWidget *run;
   GtkWidget **chbuttons;
-
+  GtkWidget *rangemenu;
 } p;
 
-int plot_range=0;
+float plot_range=0;
 int plot_scale=0;
 int plot_span=0;
 int plot_rchoice=0;
@@ -58,11 +58,35 @@
 int plot_interval=0;
 int plot_trigger=0;
 int plot_hold=0;
+int plot_type=0;
 int plot_last_update=0;
 int *active;
 
 int overslice[MAX_FILES]= {-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1};
 
+static void set_slices(int interval, int span){
+
+  /* update interval limited to < 25fps */
+  int temp = (interval < 50000 ? 50000:interval),fi;
+
+  if(temp <= span){
+    /* if the fps-limited update interval is shorter than or equal to
+       the span, we simply frame limit */
+    for(fi=0;fi<inputs;fi++){
+      blockslice[fi]=rint(rate[fi]/1000000.*temp);
+      overslice[fi]=rint(rate[fi]/1000000.*temp);
+    }
+  }else{
+    /* if the limited update interval is longer than the span, we
+       overdraw */
+    for(fi=0;fi<inputs;fi++)
+      blockslice[fi]=rint(rate[fi]/1000000.*temp);
+    for(fi=0;fi<inputs;fi++){
+      overslice[fi]=rint(rate[fi]/1000000.*interval);
+    }
+  }
+}
+
 static void replot(struct panel *p){
   /* update the waveform display; send new data */
   if(!plot_hold){
@@ -145,33 +169,37 @@
     gtk_container_forall (GTK_CONTAINER(c),set_fg,in);
 }
 
+static int rangechange_ign=0;
 static void rangechange(GtkWidget *widget,struct panel *p){
-  int choice=gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
-  plot_rchoice=choice;
-  switch(choice){
-  case 0:
-    plot_range=0;
-    break;
-  case 1:
-    plot_range=-6;
-    break;
-  case 2:
-    plot_range=-14;
-    break;
-  case 3:
-    plot_range=-20;
-    break;
-  case 4:
-    plot_range=-40;
-    break;
-  case 5:
-    plot_range=-60;
-    break;
+  if(!rangechange_ign){
+    int choice=gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+    plot_rchoice=choice;
+    switch(choice){
+    case 0:
+      plot_range=1;
+      break;
+    case 1:
+      plot_range=.5;
+      break;
+    case 2:
+      plot_range=.2;
+      break;
+    case 3:
+      plot_range=.1;
+      break;
+    case 4:
+      plot_range=.01;
+      break;
+    case 5:
+      plot_range=.001;
+      break;
+    }
+    plot_setting(PLOT(p->plot),plot_range,plot_scale,plot_interval,plot_span,plot_rchoice,plot_schoice,plot_spanchoice,plot_type,NULL,NULL);
   }
-  plot_setting(PLOT(p->plot),plot_range,plot_scale,plot_interval,plot_span,plot_rchoice,plot_schoice,plot_spanchoice,NULL,NULL);
 }
 
 static void scalechange(GtkWidget *widget,struct panel *p){
+  int i;
   int choice=gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
   plot_schoice=choice;
   switch(choice){
@@ -191,7 +219,36 @@
     plot_scale=-160;
     break;
   }
-  plot_setting(PLOT(p->plot),plot_range,plot_scale,plot_interval,plot_span,plot_rchoice,plot_schoice,plot_spanchoice,NULL,NULL);
+
+  rangechange_ign=1;
+  if(choice==0){
+    char *entries[]={"1.0",
+                     "0.5",
+                     "0.2",
+                     "0.1",
+                     "0.01",
+                     "0.001"};
+    for(i=0;i<6;i++){
+      gtk_combo_box_remove_text (GTK_COMBO_BOX (p->rangemenu), i);
+      gtk_combo_box_insert_text (GTK_COMBO_BOX (p->rangemenu), i, entries[i]);
+    }
+
+  }else{
+    char *entries[]={"0dB",
+                     "-6dB",
+                     "-14dB",
+                     "-20dB",
+                     "-40dB",
+                     "-60dB"};
+    for(i=0;i<6;i++){
+      gtk_combo_box_remove_text (GTK_COMBO_BOX (p->rangemenu), i);
+      gtk_combo_box_insert_text (GTK_COMBO_BOX (p->rangemenu), i, entries[i]);
+    }
+  }
+  gtk_combo_box_set_active(GTK_COMBO_BOX(p->rangemenu),plot_rchoice);
+  rangechange_ign=0;
+
+  plot_setting(PLOT(p->plot),plot_range,plot_scale,plot_interval,plot_span,plot_rchoice,plot_schoice,plot_spanchoice,plot_type,NULL,NULL);
 }
 
 static void spanchange(GtkWidget *widget,struct panel *p){
@@ -239,25 +296,9 @@
     break;
   }
 
-  /* update interval limited to < 25fps */
-  int temp = (plot_interval < 50000 ? 50000:plot_interval),fi;
+  set_slices(plot_interval,plot_span);
 
-  if(temp <= plot_span){
-    /* if the fps-limited update interval is shorter than or equal to
-       the span, we simply frame limit */
-    for(fi=0;fi<inputs;fi++){
-      blockslice[fi]=rate[fi]*temp/1000000;
-      overslice[fi]=rate[fi]*temp/1000000;
-    }
-  }else{
-    /* if the limited update interval is longer than the span, we
-       overdraw */
-    for(fi=0;fi<inputs;fi++)
-      blockslice[fi]=rate[fi]*temp/1000000;
-    for(fi=0;fi<inputs;fi++)
-      overslice[fi]=rate[fi]*plot_interval/1000000;
-  }
-  plot_setting(PLOT(p->plot),plot_range,plot_scale,plot_interval,plot_span,plot_rchoice,plot_schoice,plot_spanchoice,blockslice,overslice);
+  plot_setting(PLOT(p->plot),plot_range,plot_scale,plot_interval,plot_span,plot_rchoice,plot_schoice,plot_spanchoice,plot_type,blockslice,overslice);
 }
 
 /* intervals that are >= the span and would result in > 25fps are overdrawn */
@@ -305,25 +346,9 @@
     break;
   }
 
-  /* update interval limited to < 25fps */
-  int temp = (plot_interval < 50000 ? 50000:plot_interval),fi;
+  set_slices(plot_interval,plot_span);
 
-  if(temp <= plot_span){
-    /* if the fps-limited update interval is shorter than or equal to
-       the span, we simply frame limit */
-    for(fi=0;fi<inputs;fi++){
-      blockslice[fi]=rate[fi]*temp/1000000;
-      overslice[fi]=rate[fi]*temp/1000000;
-    }
-  }else{
-    /* if the limited update interval is longer than the span, we
-       overdraw */
-    for(fi=0;fi<inputs;fi++)
-      blockslice[fi]=rate[fi]*temp/1000000;
-    for(fi=0;fi<inputs;fi++)
-      overslice[fi]=rate[fi]*plot_interval/1000000;
-  }
-  plot_setting(PLOT(p->plot),plot_range,plot_scale,plot_interval,plot_span,plot_rchoice,plot_schoice,plot_spanchoice,blockslice,overslice);
+  plot_setting(PLOT(p->plot),plot_range,plot_scale,plot_interval,plot_span,plot_rchoice,plot_schoice,plot_spanchoice,plot_type,blockslice,overslice);
 }
 
 static void triggerchange(GtkWidget *widget,struct panel *p){
@@ -352,6 +377,11 @@
   plot_draw(PLOT(p->plot));
 }
 
+static void plotchange(GtkWidget *widget,struct panel *p){
+  plot_type=gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+  plot_setting(PLOT(p->plot),plot_range,plot_scale,plot_interval,plot_span,plot_rchoice,plot_schoice,plot_spanchoice,plot_type,blockslice,overslice);
+}
+
 static void loopchange(GtkWidget *widget,struct panel *p){
   acc_loop=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
 }
@@ -482,12 +512,15 @@
 
       for(i=ch;i<ch+channels[fi];i++){
 	GtkWidget *button=panel->chbuttons[i]=gtk_toggle_button_new();
+        GdkColor rgb = chcolor(i);
 
         sprintf(buffer,"channel %d", i-ch);
         gtk_button_set_label(GTK_BUTTON(button),buffer);
 
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),1);  
 	g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (chlabels), panel);
+
+        set_fg(button,&rgb);
 	gtk_box_pack_start(GTK_BOX(rightbox),button,0,0,0);
       }
 
@@ -505,77 +538,100 @@
   /* add the action buttons */
   /* range */
   {
+    GtkWidget *box=gtk_hbox_new(1,1);
+
     GtkWidget *menu=gtk_combo_box_new_text();
-    char *entries[]={"\xC2\xB1""1.0 / 0dBFS",
-                     "\xC2\xB1""0.5 / -6dBFS",
-                     "\xC2\xB1""0.2 / -14dBFS",
-                     "\xC2\xB1""0.1 / -20dBFS",
-                     "\xC2\xB1""0.01 / -40dBFS",
-                     "\xC2\xB1""0.001 / -60dBFS"};
+    char *entries[]={"","","","","",""};
     for(i=0;i<6;i++)
       gtk_combo_box_append_text (GTK_COMBO_BOX (menu), entries[i]);
-    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
-    gtk_box_pack_start(GTK_BOX(bbox),menu,0,0,0);
     g_signal_connect (G_OBJECT (menu), "changed",
 		      G_CALLBACK (rangechange), panel);
-  }
+    panel->rangemenu = menu;
 
-  /* scale */
-  {
-    GtkWidget *menu=gtk_combo_box_new_text();
-    char *entries[]={"linear","-65dB+","-96dB+","-120dB+","-160dB+"};
+    GtkWidget *menu2=gtk_combo_box_new_text();
+    char *entries2[]={"linear","-65dB","-96dB","-120dB","-160dB"};
     for(i=0;i<5;i++)
-      gtk_combo_box_append_text (GTK_COMBO_BOX (menu), entries[i]);
+      gtk_combo_box_append_text (GTK_COMBO_BOX (menu2), entries2[i]);
+    g_signal_connect (G_OBJECT (menu2), "changed",
+		      G_CALLBACK (scalechange), panel);
+
+    gtk_box_pack_start(GTK_BOX(box),menu2,1,1,0);
+    gtk_box_pack_start(GTK_BOX(box),menu,1,1,0);
+    gtk_box_pack_start(GTK_BOX(bbox),box,0,0,0);
     gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
-    gtk_box_pack_start(GTK_BOX(bbox),menu,0,0,0);
-    g_signal_connect (G_OBJECT (menu), "changed",
-		      G_CALLBACK (scalechange), panel);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(menu2),0);
   }
 
   /* span */
   {
+    GtkWidget *box=gtk_hbox_new(1,1);
+    GtkWidget *label=gtk_label_new ("span: ");
+    gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
+
     GtkWidget *menu=gtk_combo_box_new_text();
-    char *entries[]={"1s span",
-                     "500ms span","200ms span","100ms span",
-                     "50ms span","20ms span","10ms span",
-                     "5ms span","2ms span","1ms span",
-                     "500\xCE\xBCs span","200\xCE\xBCs span",
-                     "100\xCE\xBCs span"};
+    char *entries[]={"1s",
+                     "500ms","200ms","100ms",
+                     "50ms","20ms","10ms",
+                     "5ms","2ms","1ms",
+                     "500\xCE\xBCs","200\xCE\xBCs",
+                     "100\xCE\xBCs"};
     for(i=0;i<13;i++)
       gtk_combo_box_append_text (GTK_COMBO_BOX (menu), entries[i]);
-    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
-    gtk_box_pack_start(GTK_BOX(bbox),menu,0,0,0);
     g_signal_connect (G_OBJECT (menu), "changed",
 		      G_CALLBACK (spanchange), panel);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
+
+
+    gtk_box_pack_start(GTK_BOX(box),label,1,1,0);
+    gtk_box_pack_start(GTK_BOX(box),menu,1,1,0);
+    gtk_box_pack_start(GTK_BOX(bbox),box,0,0,0);
   }
 
   /* trigger */
   {
+    GtkWidget *box=gtk_hbox_new(1,1);
+
     GtkWidget *menu=gtk_combo_box_new_text();
     char *entries[]={"free run"};
     for(i=0;i<1;i++)
       gtk_combo_box_append_text (GTK_COMBO_BOX (menu), entries[i]);
     gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
-    gtk_box_pack_start(GTK_BOX(bbox),menu,0,0,0);
     g_signal_connect (G_OBJECT (menu), "changed",
 		      G_CALLBACK (triggerchange), panel);
+
+    /* interval */
+
+    GtkWidget *menu2=gtk_combo_box_new_text();
+    char *entries2[]={"1s",
+                      "500ms","200ms","100ms",
+                      "50ms","20ms","10ms",
+                      "5ms","2ms","1ms",
+                      "500\xCE\xBCs","200\xCE\xBCs",
+                      "100\xCE\xBCs"};
+    for(i=0;i<13;i++)
+      gtk_combo_box_append_text (GTK_COMBO_BOX (menu2), entries2[i]);
+    g_signal_connect (G_OBJECT (menu2), "changed",
+		      G_CALLBACK (intervalchange), panel);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(menu2),3);
+
+
+    gtk_box_pack_start(GTK_BOX(box),menu,1,1,0);
+    gtk_box_pack_start(GTK_BOX(box),menu2,1,1,0);
+    gtk_box_pack_start(GTK_BOX(bbox),box,0,0,0);
+
+
   }
 
-  /* interval */
+  /* plot type */
   {
     GtkWidget *menu=gtk_combo_box_new_text();
-    char *entries[]={"1s interval",
-                     "500ms interval","200ms interval","100ms interval",
-                     "50ms interval","20ms interval","10ms interval",
-                     "5ms interval","2ms interval","1ms interval",
-                     "500\xCE\xBCs interval","200\xCE\xBCs interval",
-                     "100\xCE\xBCsinterval "};
-    for(i=0;i<13;i++)
+    char *entries[]={"zero-hold","interpolated","lollipop"};
+    for(i=0;i<3;i++)
       gtk_combo_box_append_text (GTK_COMBO_BOX (menu), entries[i]);
-    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),3);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(menu),0);
+    g_signal_connect (G_OBJECT (menu), "changed",
+		      G_CALLBACK (plotchange), panel);
     gtk_box_pack_start(GTK_BOX(bbox),menu,0,0,0);
-    g_signal_connect (G_OBJECT (menu), "changed",
-		      G_CALLBACK (intervalchange), panel);
   }
 
   {
@@ -605,9 +661,9 @@
     button=gtk_toggle_button_new_with_mnemonic("_loop");
     gtk_widget_add_accelerator (button, "activate", panel->group, GDK_l, 0, 0);
     g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (loopchange), panel);
-    gtk_box_pack_start(GTK_BOX(box),button,1,1,0);
     gtk_widget_set_sensitive(button,global_seekable);
 
+    gtk_box_pack_start(GTK_BOX(box),button,1,1,0);
     gtk_box_pack_start(GTK_BOX(bbox),box,0,0,0);
   }
 

Modified: trunk/spectrum/wave_plot.c
===================================================================
--- trunk/spectrum/wave_plot.c	2012-04-12 14:29:17 UTC (rev 18229)
+++ trunk/spectrum/wave_plot.c	2012-04-13 06:39:51 UTC (rev 18230)
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include <string.h>
+#include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 #include "wave_plot.h"
 
@@ -35,15 +36,15 @@
   int width=widget->allocation.width-p->padx;
   int i,j;
 
-  p->xgrids=10;
+  p->xgrids=11;
   p->xtics=30;
 
   for(i=0;i<p->xgrids;i++)
-    p->xgrid[i]=rint(i/(float)(p->xgrids) * (width-1))+p->padx;
+    p->xgrid[i]=rint(i/(float)(p->xgrids-1) * (width-1))+p->padx;
 
   for(i=0,j=0;i<p->xtics;i++,j++){
     if(j%4==0)j++;
-    p->xtic[i]=rint(j/(float)(p->xgrids*4) * (width-1))+p->padx;
+    p->xtic[i]=rint(j/(float)((p->xgrids-1)*4) * (width-1))+p->padx;
   }
 }
 
@@ -111,7 +112,7 @@
     gdk_draw_rectangle(p->backing,gc,1,0,height-p->pady,width,p->pady);
 
     gc=parent->style->white_gc;
-    gdk_draw_rectangle(p->backing,gc,1,padx,0,width-padx,height-p->pady+1);
+    gdk_draw_rectangle(p->backing,gc,1,padx,0,width-padx,height-p->pady);
   }
 
   /* draw the light x grid */
@@ -176,10 +177,7 @@
     for(i=-8;i<9;i+=4){
       int y=rint(center + center*i/9);
 
-      if(i==0)
-        gdk_draw_line(p->backing,widget->style->black_gc,padx,y,width,y);
-      else
-        gdk_draw_line(p->backing,p->drawgc,padx,y,width,y);
+      gdk_draw_line(p->backing,p->drawgc,padx,y,width,y);
 
       pango_layout_get_pixel_size(p->y_layout[p->rchoice][p->schoice][i/4+2],
                                   &px,&py);
@@ -222,6 +220,11 @@
       gdk_draw_line(p->backing,p->drawgc,p->xgrid[i],0,p->xgrid[i],height-p->pady);
   }
 
+  /* zero line */
+  {
+    int center = (height-p->pady)/2;
+    gdk_draw_line(p->backing,widget->style->black_gc,padx,center,width,center);
+  }
 
   {
     GdkGCValues values;
@@ -232,6 +235,69 @@
 
   /* draw actual data */
   if(p->ydata){
+    int ch=0,fi,i,j,k;
+    const GdkRectangle clip = {p->padx,0,width-p->padx,height-p->pady};
+    const GdkRectangle noclip = {0,0,width,height};
+    GdkColor rgb;
+
+    gdk_gc_set_clip_rectangle (p->drawgc, &clip);
+
+    for(fi=0;fi<p->groups;fi++){
+      int copies = (int)ceil(p->blockslice[fi]/p->overslice[fi]);
+      int spann = ceil(p->rate[fi]/1000000.*p->span)+1;
+
+      for(i=ch;i<ch+p->ch[fi];i++){
+        if(p->ch_active[i]){
+          int offset=0;
+          rgb = chcolor(i);
+          gdk_gc_set_rgb_fg_color(p->drawgc,&rgb);
+
+          for(j=0;j<copies;j++){
+            float *data=p->ydata[i]+offset;
+            int wp=width-p->padx;
+            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;
+
+            switch(p->type){
+            case 0: /* zero-hold */
+
+
+
+
+
+              break;
+            case 1: /* linear interpolation */
+
+              for(k=0;k<spann-1;k++){
+                int x0 = rint(k*spani)+padx;
+                int x1 = rint((k+1)*spani)+padx;
+                if(!isnan(data[k]) && !isnan(data[k+1])){
+                  int y0 = rint(data[k]*ym)+cp;
+                  int y1 = rint(data[k+1]*ym)+cp;
+
+                  gdk_draw_line(p->backing,p->drawgc,x0,y0,x1,y1);
+                }
+              }
+
+              break;
+            case 2: /* lollipop */
+
+
+
+              break;
+            }
+
+            offset+=spann;
+          }
+        }
+      }
+      ch+=p->ch[fi];
+    }
+
+    gdk_gc_set_clip_rectangle(p->drawgc, &noclip);
+
   }
 
   {
@@ -384,42 +450,41 @@
   /* generate all the text layouts we'll need */
   /* linear X scale */
   {
-    char *labels[13][11]={
-      {"","100ms","200ms","300ms","400ms","500ms","600ms","700ms","800ms","900ms",""},
-      {"","50ms","100ms","150ms","200ms","250ms","300ms","350ms","400ms","450ms",""},
-      {"","20ms","40ms","60ms","80ms","100ms","120ms","140ms","160ms","180ms",""},
-      {"","10ms","20ms","30ms","40ms","50ms","60ms","70ms","80ms","90ms",""},
-      {"","5ms","10ms","15ms","20ms","25ms","30ms","35ms","40ms","45ms",""},
-      {"","2ms","4ms","6ms","8ms","10ms","12ms","14ms","16ms","18ms",""},
-      {"","1ms","2ms","3ms","4ms","5ms","6ms","7ms","8ms","9ms",""},
-      {"","100\xC2\xBCs","200\xC2\xBCs","300\xC2\xBCs","400\xC2\xBCs","500\xC2\xBCs",
-       "600\xC2\xBCs","700\xC2\xBCs","800\xC2\xBCs","900\xC2\xBCs",""},
-      {"","50\xC2\xBCs","100\xC2\xBCs","150\xC2\xBCs","200\xC2\xBCs","250\xC2\xBCs",
-       "300\xC2\xBCs","350\xC2\xBCs","400\xC2\xBCs","450\xC2\xBCs",""},
-      {"","20\xC2\xBCs","40\xC2\xBCs","60\xC2\xBCs","80\xC2\xBCs","100\xC2\xBCs",
-       "120\xC2\xBCs","140\xC2\xBCs","160\xC2\xBCs","180\xC2\xBCs",""},
-      {"","10\xC2\xBCs","20\xC2\xBCs","30\xC2\xBCs","40\xC2\xBCs","50\xC2\xBCs",
-       "60\xC2\xBCs","70\xC2\xBCs","80\xC2\xBCs","90\xC2\xBCs",""},
-      {"","5\xC2\xBCs","10\xC2\xBCs","15\xC2\xBCs","20\xC2\xBCs","25\xC2\xBCs",
-       "30\xC2\xBCs","35\xC2\xBCs","40\xC2\xBCs","45\xC2\xBCs",""},
-      {"","2\xC2\xBCs","4\xC2\xBCs","6\xC2\xBCs","8\xC2\xBCs","10\xC2\xBCs",
-       "12\xC2\xBCs","14\xC2\xBCs","16\xC2\xBCs","18\xC2\xBCs",""}};
+    char *labels[13][12]={
+      {"","100ms","200ms","300ms","400ms","500ms","600ms","700ms","800ms","900ms","",""},
+      {"","50ms","100ms","150ms","200ms","250ms","300ms","350ms","400ms","450ms","",""},
+      {"","20ms","40ms","60ms","80ms","100ms","120ms","140ms","160ms","180ms","",""},
+      {"","10ms","20ms","30ms","40ms","50ms","60ms","70ms","80ms","90ms","",""},
+      {"","5ms","10ms","15ms","20ms","25ms","30ms","35ms","40ms","45ms","",""},
+      {"","2ms","4ms","6ms","8ms","10ms","12ms","14ms","16ms","18ms","",""},
+      {"","1ms","2ms","3ms","4ms","5ms","6ms","7ms","8ms","9ms","",""},
+      {"",".5ms","1ms","1.5ms","2ms","2.5ms","3ms","3.5ms","4ms","4.5ms","",""},
+      {"",".2ms",".4ms",".6ms",".8ms","1ms","1.2ms","1.4ms","1.6ms","1.8ms","",""},
 
+      {"","100\xCE\xBCs","200\xCE\xBCs","300\xCE\xBCs","400\xCE\xBCs","500\xCE\xBCs",
+       "600\xCE\xBCs","700\xCE\xBCs","800\xCE\xBCs","900\xCE\xBCs","",""},
+      {"","50\xCE\xBCs","100\xCE\xBCs","150\xCE\xBCs","200\xCE\xBCs","250\xCE\xBCs",
+       "300\xCE\xBCs","350\xCE\xBCs","400\xCE\xBCs","450\xCE\xBCs","",""},
+      {"","20\xCE\xBCs","40\xCE\xBCs","60\xCE\xBCs","80\xCE\xBCs","100\xCE\xBCs",
+       "120\xCE\xBCs","140\xCE\xBCs","160\xCE\xBCs","180\xCE\xBCs","",""},
+      {"","10\xCE\xBCs","20\xCE\xBCs","30\xCE\xBCs","40\xCE\xBCs","50\xCE\xBCs",
+       "60\xCE\xBCs","70\xCE\xBCs","80\xCE\xBCs","90\xCE\xBCs","",""}};
+
     p->x_layout=calloc(13,sizeof(*p->x_layout));
-    for(i=0;i<12;i++){
-      p->x_layout[i]=calloc(11,sizeof(**p->x_layout));
-      for(j=0;j<10;j++)
+    for(i=0;i<13;i++){
+      p->x_layout[i]=calloc(12,sizeof(**p->x_layout));
+      for(j=0;j<11;j++)
         p->x_layout[i][j]=gtk_widget_create_pango_layout(ret,labels[i][j]);
     }
   }
 
   /* phase Y scale */
   {
-    char *label1[6] = {"1",".5",".2",".1",".01",".001"};
-    char *label1a[6] = {".5",".25",".1",".05",".005",".0005"};
+    char *label1[6] = {"1.0","0.5","0.2","0.1",".01",".001"};
+    char *label1a[6] = {"0.5","0.25","0.1","0.05",".005",".0005"};
 
-    char *labeln1[6] = {"-1","-.5","-.2","-.1","-.01","-.001"};
-    char *labeln1a[6] = {"-.5","-.25","-.1","-.05","-.005","-.0005"};
+    char *labeln1[6] = {"-1.0","-0.5","-0.2","-0.1","-.01","-.001"};
+    char *labeln1a[6] = {"-0.5","-0.25","-0.1","-0.05","-.005","-.0005"};
 
     char *label2[6] = {"0dB","-6dB","-14dB","-20dB","-40dB","-60dB"};
     char *label3[5] = {"0","-65dB","-96dB","-120dB","-160dB"};
@@ -486,7 +551,7 @@
   return(p->ydata);
 }
 
-void plot_setting (Plot *p, int range, int scale, int interval, int span, int rangechoice, int scalechoice, int spanchoice,
+void plot_setting (Plot *p, float range, int scale, int interval, int span, int rangechoice, int scalechoice, int spanchoice,int type,
                    int *blockslice, int *overslice){
   GtkWidget *widget=GTK_WIDGET(p);
   p->range=range;
@@ -496,6 +561,7 @@
   p->rchoice=rangechoice;
   p->schoice=scalechoice;
   p->spanchoice=spanchoice;
+  p->type=type;
 
   if(blockslice){
     if(!p->blockslice)

Modified: trunk/spectrum/wave_plot.h
===================================================================
--- trunk/spectrum/wave_plot.h	2012-04-12 14:29:17 UTC (rev 18229)
+++ trunk/spectrum/wave_plot.h	2012-04-13 06:39:51 UTC (rev 18230)
@@ -59,10 +59,11 @@
   int *ch_active;
   int total_ch;
 
-  int range;
+  float range;
   int scale;
   int interval;
   int span;
+  int type;
 
   int rchoice;
   int schoice;
@@ -98,9 +99,9 @@
 GType          plot_get_type        (void);
 GtkWidget*     plot_new             (int n, int inputs, int *channels, int *rate);
 void	       plot_refresh         (Plot *m);
-void	       plot_setting         (Plot *p, int range, int scale, int interval, int span,
+void	       plot_setting         (Plot *p, float range, int scale, int interval, int span,
                                      int rangechoice, int scalechoice, int spanchoice,
-                                     int *blockslice, int *overslice);
+                                     int type, int *blockslice, int *overslice);
 void	       plot_draw            (Plot *m);
 void	       plot_clear           (Plot *m);
 int 	       plot_width           (Plot *m);

Modified: trunk/spectrum/wave_process.c
===================================================================
--- trunk/spectrum/wave_process.c	2012-04-12 14:29:17 UTC (rev 18229)
+++ trunk/spectrum/wave_process.c	2012-04-13 06:39:51 UTC (rev 18230)
@@ -84,7 +84,7 @@
   int fi,i,j,k,ch;
 
   init_process();
-  if(!blockslice || !overslice)return NULL;
+  if(!blockslice || !overslice || !blockbuffer)return NULL;
 
   /* by channel */
   ch=0;
@@ -95,17 +95,16 @@
        ceil(blockslice/overslice) back-to-back spans */
 
     int copies = (int)ceil(blockslice[fi]/overslice[fi]);
-    int spann = rate[fi]*span/1000000;
+    int spann = ceil(rate[fi]/1000000.*span)+1;
 
     for(i=ch;i<ch+channels[fi];i++){
-      int offset=0;
+      int offset=blocksize-spann;
       float *plotdatap=plot_data[i];
-      pthread_mutex_lock(&feedback_mutex);
       for(j=0;j<copies;j++){
         float *data=blockbuffer[i]+offset;
         for(k=0;k<spann;k++)
           *(plotdatap++)=data[k];
-        offset+=overslice[fi];
+        offset-=overslice[fi];
       }
     }
     ch+=channels[fi];



More information about the commits mailing list