src/aubio_priv.h: define VERY_SMALL_NUMBER here, add KILL_DENORMAL and CEIL_DENORMAL...
authorPaul Brossier <piem@piem.org>
Mon, 28 Sep 2009 18:58:03 +0000 (20:58 +0200)
committerPaul Brossier <piem@piem.org>
Mon, 28 Sep 2009 18:58:03 +0000 (20:58 +0200)
src/aubio_priv.h
src/temporal/filter.c

index 3342377..c250663 100644 (file)
@@ -189,7 +189,15 @@ typedef enum {
 
 #define ELEM_SWAP(a,b) { register smpl_t t=(a);(a)=(b);(b)=t; }
 
-#define ISDENORMAL(f) f < 1.e-37
+#define VERY_SMALL_NUMBER 2.e-42 //1.e-37
+
+#define IS_DENORMAL(f) f < VERY_SMALL_NUMBER
+
+#define KILL_DENORMAL(f)  IS_DENORMAL(f) ? 0. : f
+#define CEIL_DENORMAL(f)  IS_DENORMAL(f) ? VERY_SMALL_NUMBER : f
+
+#define SAFE_LOG10(f) LOG10(CEIL_DENORMAL(f))
+#define SAFE_LOG(f)   LOG(CEIL_DENORMAL(f))
 
 #define UNUSED __attribute__((unused))
 
index 3d95883..f3d0c91 100644 (file)
@@ -44,7 +44,7 @@ void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out) {
     y = f->y->data[i];
     for (j = 0; j < in->length; j++) {
       /* new input */
-      if (ISDENORMAL(in->data[i][j])) {
+      if (IS_DENORMAL(in->data[i][j])) {
         x[0] = y[0] = 0.;
       } else {
         x[0] = in->data[i][j];