[xiph-commits] r18270 - trunk/spectrum
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Fri May 11 12:54:59 PDT 2012
Author: xiphmont
Date: 2012-05-11 12:54:59 -0700 (Fri, 11 May 2012)
New Revision: 18270
Modified:
trunk/spectrum/analyzer.h
trunk/spectrum/spec_panel.c
trunk/spectrum/spec_process.c
trunk/spectrum/version.h
Log:
Add 'average' history mode
extend to_dB() to actually work down to -200dB (requires double
precision log)
Modified: trunk/spectrum/analyzer.h
===================================================================
--- trunk/spectrum/analyzer.h 2012-05-08 22:50:54 UTC (rev 18269)
+++ trunk/spectrum/analyzer.h 2012-05-11 19:54:59 UTC (rev 18270)
@@ -45,7 +45,7 @@
extern int blocksize;
static inline float todB(float x){
- return logf((x)*(x)+1e-45f)*4.34294480f;
+ return log((double)(x)*(x)+1e-50)*4.34294480;
}
#ifdef UGLY_IEEE754_FLOAT32_HACK
Modified: trunk/spectrum/spec_panel.c
===================================================================
--- trunk/spectrum/spec_panel.c 2012-05-08 22:50:54 UTC (rev 18269)
+++ trunk/spectrum/spec_panel.c 2012-05-11 19:54:59 UTC (rev 18270)
@@ -579,7 +579,6 @@
GtkWidget *bbox=gtk_vbox_new(0,0);
/* add the action buttons */
- /* scale */
{
GtkWidget *menu=gtk_combo_box_new_text();
char *entries[]={"unsmoothed","1/24th octave","1/12th octave","1/3 octave"};
@@ -591,9 +590,10 @@
G_CALLBACK (reschange), panel);
}
+ /* scale */
{
GtkWidget *menu=gtk_combo_box_new_text();
- char *entries[]={"log scale","ISO log scale","linear scale"};
+ char *entries[]={"log frequency","ISO frequency","linear frequency"};
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),plot_scale);
@@ -620,8 +620,8 @@
/* mode */
{
GtkWidget *menu=gtk_combo_box_new_text();
- char *entries[]={"realtime","maximum","accumulate"};
- for(i=0;i<3;i++)
+ char *entries[]={"realtime","maximum","accumulate","average"};
+ for(i=0;i<4;i++)
gtk_combo_box_append_text (GTK_COMBO_BOX (menu), entries[i]);
gtk_combo_box_set_active(GTK_COMBO_BOX(menu),plot_mode);
gtk_box_pack_start(GTK_BOX(bbox),menu,0,0,0);
Modified: trunk/spectrum/spec_process.c
===================================================================
--- trunk/spectrum/spec_process.c 2012-05-08 22:50:54 UTC (rev 18269)
+++ trunk/spectrum/spec_process.c 2012-05-11 19:54:59 UTC (rev 18270)
@@ -323,6 +323,7 @@
int ch,ci,i,j,fi;
float **data;
float **ph;
+ float *normptr;
float maxrate=-1.;
float nyq;
@@ -508,7 +509,8 @@
}
/* mode selects the base data set */
- switch(mode){
+ normptr=NULL;
+ switch(mode){
case 0: /* independent / instant */
data=feedback_instant;
ph=ph_instant;
@@ -517,10 +519,15 @@
data=feedback_max;
ph=ph_max;
break;
- case 2:
+ case 2: /* independent / accumulate */
data=feedback_acc;
ph=ph_acc;
break;
+ case 3: /* independent / average */
+ data=feedback_acc;
+ ph=ph_acc;
+ normptr=feedback_count;
+ break;
}
ch=0;
@@ -530,6 +537,7 @@
for(fi=0;fi<inputs;fi++){
float *L = xmappingL[fi];
float *H = xmappingH[fi];
+ float normalize = normptr ? 1./normptr[fi] : 1.;
switch(link){
case LINK_INDEPENDENT:
@@ -557,6 +565,7 @@
sum+=m[last]*del;
}
+ sum*=normalize;
sum=todB_a(&sum)*.5;
if(sum>*ymax)*ymax=sum;
y[i]=sum;
@@ -595,7 +604,8 @@
}
for(i=0;i<width;i++){
- float sum=todB_a(y+i)*.5;
+ float sum=y[i]*normalize;
+ sum=todB_a(&sum)*.5;
if(sum>*ymax)*ymax=sum;
y[i]=sum;
}
@@ -642,6 +652,7 @@
for(i=0;i<width;i++){
float v = (y[i]>0?y[i]:0);
+ v*=normalize;
float sum=todB_a(&v)*.5;
if(sum>*ymax)*ymax=sum;
y[i]=sum;
@@ -679,6 +690,7 @@
r[i]=sum;
}else{
sum=(r[i]>sum?0.f:sum-r[i]);
+ sum*=normalize;
y[i]=todB_a(&sum)*.5;
if(y[i]>*ymax)*ymax=y[i];
}
@@ -725,8 +737,8 @@
}else{
/* the shunt */
/* 'r' collected at source, 'sum' across the shunt */
- float V=sqrt(r[i]);
- float S=sqrt(sum);
+ float V=sqrt(r[i]*normalize);
+ float S=sqrt(sum*normalize);
if(S>(1e-5) && V>S){
y[i] = shunt*(V-S)/S;
Modified: trunk/spectrum/version.h
===================================================================
--- trunk/spectrum/version.h 2012-05-08 22:50:54 UTC (rev 18269)
+++ trunk/spectrum/version.h 2012-05-11 19:54:59 UTC (rev 18270)
@@ -1,2 +1,2 @@
#define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Tue May 8 18:49:40 EDT 2012] */
+/* DO NOT EDIT: Automated versioning hack [Thu May 10 03:59:15 EDT 2012] */
More information about the commits
mailing list