[xiph-commits] r18433 - trunk/spectrum
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Sun Jul 1 08:56:10 PDT 2012
Author: xiphmont
Date: 2012-07-01 08:56:10 -0700 (Sun, 01 Jul 2012)
New Revision: 18433
Modified:
trunk/spectrum/analyzer.h
trunk/spectrum/spec_process.c
trunk/spectrum/version.h
Log:
add noise suppression to phase reading
Modified: trunk/spectrum/analyzer.h
===================================================================
--- trunk/spectrum/analyzer.h 2012-07-01 15:41:20 UTC (rev 18432)
+++ trunk/spectrum/analyzer.h 2012-07-01 15:56:10 UTC (rev 18433)
@@ -72,6 +72,7 @@
#define fromdB(x) (exp((x)*.11512925f))
static inline float fast_atan_cmp(float y, float x) {
+ if(y*y<1e-12f && x*x<1e-12f) return NAN;
if(x*x>y*y)
return y/x + copysignf(2.,y) - copysignf(2.,y*x);
else
Modified: trunk/spectrum/spec_process.c
===================================================================
--- trunk/spectrum/spec_process.c 2012-07-01 15:41:20 UTC (rev 18432)
+++ trunk/spectrum/spec_process.c 2012-07-01 15:56:10 UTC (rev 18433)
@@ -519,6 +519,11 @@
return (c - d*2*M_PI - M_PI);
}
+static float wrap_atan2f(float y, float x){
+ if(y*y<1e-12f && x*x<1e-12f) return NAN;
+ return atan2f(y,x);
+}
+
static void ph_minmax(float *R, float *I, float *out,
float *pmin, float *pmax, int width, float adj,
float *L, float *M, float *H){
@@ -538,8 +543,8 @@
if(first==last){
float m = (H[i]+L[i])*.5-first;
- float aP = aadd(atan2f(I[first],R[first]),adj*first);
- float bP = aadd(atan2f(I[first+1],R[first+1]),adj*(first+1));
+ float aP = aadd(wrap_atan2f(I[first],R[first]),adj*first);
+ float bP = aadd(wrap_atan2f(I[first+1],R[first+1]),adj*(first+1));
min=max = (aP+(bP-aP)*m)*(360/M_PI/2);
}else{
int min_i,max_i;
@@ -557,11 +562,11 @@
}
}
- min=aadd(atan2f(I[min_i],R[min_i]),adj*min_i)*(360/M_PI/2);
+ min=aadd(wrap_atan2f(I[min_i],R[min_i]),adj*min_i)*(360/M_PI/2);
if(max_i==min_i)
max=min;
else
- max=aadd(atan2f(I[max_i],R[max_i]),adj*max_i)*(360/M_PI/2);
+ max=aadd(wrap_atan2f(I[max_i],R[max_i]),adj*max_i)*(360/M_PI/2);
}
if(max>*pmax)*pmax=max;
@@ -750,7 +755,7 @@
I += (iI[last]*(1.-m) + iI[last+1]*m)*del;
}
- min=max=P = atan2f(I,R)*(360/2/M_PI);
+ min=max=P = wrap_atan2f(I,R)*(360/2/M_PI);
if(max>*pmax)*pmax=max;
if(min<*pmin)*pmin=min;
@@ -841,7 +846,7 @@
I = rotI + iI[last+1]*m*del;
}
- min=max=P = aadd(atan2f(I,R),adj*(last+1))*(360/M_PI/2);
+ min=max=P = aadd(wrap_atan2f(I,R),adj*(last+1))*(360/M_PI/2);
if(max>*pmax)*pmax=max;
if(min<*pmin)*pmin=min;
Modified: trunk/spectrum/version.h
===================================================================
--- trunk/spectrum/version.h 2012-07-01 15:41:20 UTC (rev 18432)
+++ trunk/spectrum/version.h 2012-07-01 15:56:10 UTC (rev 18433)
@@ -1,2 +1,2 @@
#define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Sun Jul 1 11:40:54 EDT 2012] */
+/* DO NOT EDIT: Automated versioning hack [Sun Jul 1 11:51:56 EDT 2012] */
More information about the commits
mailing list