[xiph-commits] r18269 - trunk/spectrum
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Tue May 8 15:50:54 PDT 2012
Author: xiphmont
Date: 2012-05-08 15:50:54 -0700 (Tue, 08 May 2012)
New Revision: 18269
Modified:
trunk/spectrum/analyzer.h
trunk/spectrum/spec_panel.c
trunk/spectrum/spec_plot.c
trunk/spectrum/spec_plot.h
trunk/spectrum/spec_process.c
trunk/spectrum/spectrum.c
trunk/spectrum/version.h
Log:
Plot fixes, depth of scale fix
add depth to 200dB
Modified: trunk/spectrum/analyzer.h
===================================================================
--- trunk/spectrum/analyzer.h 2012-05-08 02:51:57 UTC (rev 18268)
+++ trunk/spectrum/analyzer.h 2012-05-08 22:50:54 UTC (rev 18269)
@@ -45,7 +45,7 @@
extern int blocksize;
static inline float todB(float x){
- return logf((x)*(x)+1e-30f)*4.34294480f;
+ return logf((x)*(x)+1e-45f)*4.34294480f;
}
#ifdef UGLY_IEEE754_FLOAT32_HACK
@@ -78,7 +78,7 @@
extern int eventpipe[2];
-extern void panel_go(int argc,char *argv[]);
+extern void panel_go(int argc,char *argv[], int bold);
extern int input_load();
extern void *process_thread(void *dummy);
extern void process_dump(int mode);
Modified: trunk/spectrum/spec_panel.c
===================================================================
--- trunk/spectrum/spec_panel.c 2012-05-08 02:51:57 UTC (rev 18268)
+++ trunk/spectrum/spec_panel.c 2012-05-08 22:50:54 UTC (rev 18269)
@@ -180,6 +180,9 @@
case 5: /*140dB */
plot_depth=140;
break;
+ case 6: /*200dB */
+ plot_depth=200;
+ break;
}
plot_setting(PLOT(p->plot),plot_res,plot_scale,plot_mode,plot_link,plot_depth,plot_noise);
}
@@ -449,7 +452,7 @@
}
extern char *version;
-void panel_create(struct panel *panel){
+void panel_create(struct panel *panel, int bold){
int i;
GtkWidget *topplace,*topal,*topalb;
@@ -514,7 +517,7 @@
G_CALLBACK (shutdown), NULL);
/* add the spectrum plot box */
- panel->plot=plot_new(blocksize/2+1,inputs,channels,rate);
+ panel->plot=plot_new(blocksize/2+1,inputs,channels,rate,bold);
gtk_box_pack_end(GTK_BOX(leftbox),panel->plot,1,1,0);
gtk_box_pack_start(GTK_BOX(mainbox),leftbox,1,1,0);
@@ -604,14 +607,14 @@
/* depth */
{
GtkWidget *menu=gtk_combo_box_new_text();
- char *entries[]={"1dB","10dB","20dB","45dB","90dB","140dB"};
- for(i=0;i<6;i++)
+ char *entries[]={"1dB","10dB","20dB","45dB","90dB","140dB","200dB"};
+ for(i=0;i<7;i++)
gtk_combo_box_append_text (GTK_COMBO_BOX (menu), entries[i]);
gtk_box_pack_start(GTK_BOX(bbox),menu,0,0,0);
g_signal_connect (G_OBJECT (menu), "changed",
G_CALLBACK (depthchange), panel);
- gtk_combo_box_set_active(GTK_COMBO_BOX(menu),5);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(menu),4);
}
/* mode */
@@ -759,7 +762,7 @@
return 1;
}
-void panel_go(int argc,char *argv[]){
+void panel_go(int argc,char *argv[],int bold){
char *homedir=getenv("HOME");
int found=0;
memset(&p,0,sizeof(p));
@@ -814,7 +817,7 @@
gtk_rc_add_default_file("spectrum-gtkrc");
gtk_init (&argc, &argv);
- panel_create(&p);
+ panel_create(&p, bold);
animate_fish(&p);
/* set up watching the event pipe */
Modified: trunk/spectrum/spec_plot.c
===================================================================
--- trunk/spectrum/spec_plot.c 2012-05-08 02:51:57 UTC (rev 18268)
+++ trunk/spectrum/spec_plot.c 2012-05-08 22:50:54 UTC (rev 18269)
@@ -248,10 +248,12 @@
}
{
+ const GdkRectangle noclip = {0,0,width,height};
GdkGCValues values;
//gdk_gc_get_values(p->drawgc,&values);
values.line_width=1;
gdk_gc_set_values(p->drawgc,&values,GDK_GC_LINE_WIDTH);
+ gdk_gc_set_clip_rectangle (p->drawgc, &noclip);
}
/* clear the old rectangle out */
@@ -460,14 +462,20 @@
int ymid = rint(height-p->pady-1 - (height-p->pady) * ydel);
if(ymid>=height-p->pady)break;
+
if(ymid>=0){
int px,py;
- pango_layout_get_pixel_size(p->db_layout[yval/100+1400],&px,&py);
+ int label = yval/100+2000;
- gdk_draw_layout (p->backing,
- widget->style->black_gc,
- padx-px-2, ymid-py/2,
- p->db_layout[yval/100+1400]);
+ if(label>=0 && label<=4000){
+ pango_layout_get_pixel_size(p->db_layout[yval/100+2000],&px,&py);
+
+ gdk_draw_layout (p->backing,
+ widget->style->black_gc,
+ padx-px-2, ymid-py/2,
+ p->db_layout[yval/100+2000]);
+ }
+
gdk_draw_line(p->backing,p->drawgc,padx,ymid,width,ymid);
}
yval-=majordel;
@@ -556,7 +564,7 @@
}
- gdk_gc_set_line_attributes(p->drawgc,2,GDK_LINE_SOLID,GDK_CAP_BUTT,
+ gdk_gc_set_line_attributes(p->drawgc,p->bold+1,GDK_LINE_SOLID,GDK_CAP_BUTT,
GDK_JOIN_MITER);
/* draw actual data */
@@ -611,13 +619,6 @@
cho+=p->ch[gi];
}
}
-
- /* remove clip rectangle */
- {
- const GdkRectangle noclip = {0,0,width,height};
- gdk_gc_set_clip_rectangle (p->drawgc, &noclip);
- }
-
}
static void draw_and_expose(GtkWidget *widget){
@@ -798,7 +799,7 @@
return m_type;
}
-GtkWidget* plot_new (int size, int groups, int *channels, int *rate){
+GtkWidget* plot_new (int size, int groups, int *channels, int *rate, int bold){
GtkWidget *ret= GTK_WIDGET (g_object_new (plot_get_type (), NULL));
Plot *p=PLOT(ret);
int g,i;
@@ -815,6 +816,7 @@
p->ch=channels;
p->rate=rate;
p->maxrate=maxrate;
+ p->bold=bold;
if(maxrate > 100000){
p->lin_major = 10000.;
@@ -901,13 +903,13 @@
/* dB Y scale */
{
char buf[10];
- p->db_layout=calloc(2811,sizeof(*p->db_layout));
- for(i=-1400;i<1400;i++){
+ p->db_layout=calloc(4002,sizeof(*p->db_layout));
+ for(i=-2000;i<=2000;i++){
if(i%10==0)
snprintf(buf,10,"%ddB",i/10);
else
snprintf(buf,10,"%.1fdB",i*.1);
- p->db_layout[i+1400]=gtk_widget_create_pango_layout(ret,buf);
+ p->db_layout[i+2000]=gtk_widget_create_pango_layout(ret,buf);
}
}
@@ -1010,8 +1012,8 @@
p->phtimer = TIMERFRAMES;
}
- if(ymax<p->depth-140.)ymax=p->depth-140.;
- if(ymax>140.)ymax=140.;
+ if(ymax<p->depth-p->ymax_limit)ymax=p->depth-p->ymax_limit;
+ if(ymax>p->ymax_limit)ymax=p->ymax_limit;
if(pmax>180)pmax=180;
if(pmin<-180)pmin=-180;
@@ -1031,7 +1033,7 @@
p->disp_pmin = p->pmin;
/* finally, align phase/response zeros on phase graphs */
- if(p->disp_ymax>-140){
+ if(p->disp_ymax>-p->ymax_limit){
if(p->link == LINK_PHASE){
/* In a phase/response graph, 0dB/0degrees are bound and always on-screen. */
float mzero = (height-1)/p->disp_depth*p->disp_ymax;
@@ -1067,7 +1069,7 @@
for(i=0;i<p->total_ch;i++)
for(j=0;j<width;j++)
p->ydata[i][j]=NAN;
- p->ymax=p->depth-140;
+ p->ymax=p->depth-p->ymax_limit;
p->pmax=0;
p->pmin=0;
draw_and_expose(widget);
@@ -1086,7 +1088,12 @@
p->link=link;
p->noise=noise;
- p->ymax=-140;
+ if(depth>140)
+ p->ymax_limit=depth;
+ else
+ p->ymax_limit=140;
+
+ p->ymax=-p->ymax_limit;
p->pmax=0;
p->pmin=0;
Modified: trunk/spectrum/spec_plot.h
===================================================================
--- trunk/spectrum/spec_plot.h 2012-05-08 02:51:57 UTC (rev 18268)
+++ trunk/spectrum/spec_plot.h 2012-05-08 22:50:54 UTC (rev 18269)
@@ -99,12 +99,16 @@
float disp_pmax;
float disp_pmin;
+ float ymax_limit;
+
float padx;
float phax;
float pady;
int ymaxtimer;
int phtimer;
+
+ int bold;
};
struct _PlotClass{
@@ -114,7 +118,7 @@
};
GType plot_get_type (void);
-GtkWidget* plot_new (int n, int inputs, int *channels, int *rate);
+GtkWidget* plot_new (int n, int inputs, int *channels, int *rate, int bold);
void plot_refresh (Plot *m, int *process);
void plot_setting (Plot *m, int res, int scale, int mode, int link, int depth, int noise);
void plot_draw (Plot *m);
Modified: trunk/spectrum/spec_process.c
===================================================================
--- trunk/spectrum/spec_process.c 2012-05-08 02:51:57 UTC (rev 18268)
+++ trunk/spectrum/spec_process.c 2012-05-08 22:50:54 UTC (rev 18269)
@@ -524,7 +524,7 @@
}
ch=0;
- *ymax = -150.;
+ *ymax = -210.;
*pmax = -180.;
*pmin = 180.;
for(fi=0;fi<inputs;fi++){
@@ -743,7 +743,7 @@
falloffs of > 40dB or an original test magnitude under
-70dB. */
{
- float max = -140;
+ float max = -200;
for(i=0;i<width;i++){
float v = r[i] = todB_a(r+i)*.5;
if(v>max)max=v;
Modified: trunk/spectrum/spectrum.c
===================================================================
--- trunk/spectrum/spectrum.c 2012-05-08 02:51:57 UTC (rev 18268)
+++ trunk/spectrum/spectrum.c 2012-05-08 22:50:54 UTC (rev 18269)
@@ -35,6 +35,7 @@
char *inputname[MAX_FILES];
int inputs=0;
int blocksize = 131072;
+int bold=0;
void handler(int sig){
signal(sig,SIG_IGN);
@@ -55,9 +56,10 @@
gtk_main_quit();
}
-const char *optstring = "-r:c:EeBlb:suhF:";
+const char *optstring = "-r:c:EeBlb:suhF:T";
struct option options [] = {
+ {"bold",no_argument,NULL,'T'},
{"rate",required_argument,NULL,'r'},
{"channels",required_argument,NULL,'c'},
{"big-endian",no_argument,NULL,'E'},
@@ -83,6 +85,7 @@
" PCM. Default bit depth is normally read from\n"
" the file/stream header or set to 16 bits\n"
" for raw input.\n"
+" -T --bold : plot spectrum with thicker/bolder lines.\n"
" -B -E --big-endian : Force input to be read as big endian.\n"
" Default endianness is normally read from the\n"
" file/stream header or set to host"
@@ -129,6 +132,9 @@
}
inputname[inputs++]=strdup(optarg);
break;
+ case 'T':
+ bold = 1;
+ break;
case 'b':
/* force bit width */
{
@@ -290,7 +296,7 @@
}
/* go */
- panel_go(argc,argv);
+ panel_go(argc,argv,bold);
return(0);
}
Modified: trunk/spectrum/version.h
===================================================================
--- trunk/spectrum/version.h 2012-05-08 02:51:57 UTC (rev 18268)
+++ trunk/spectrum/version.h 2012-05-08 22:50:54 UTC (rev 18269)
@@ -1,2 +1,2 @@
#define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Mon Apr 23 01:09:25 EDT 2012] */
+/* DO NOT EDIT: Automated versioning hack [Tue May 8 18:49:40 EDT 2012] */
More information about the commits
mailing list