diff examples/puredata/xtract~.c @ 42:84e69b155098

Numerous fixes, see ChangeLog
author Jamie Bullock <jamie@postlude.co.uk>
date Tue, 12 Dec 2006 21:47:42 +0000
parents afb9e6fee244
children 4a36f70a76e9
line wrap: on
line diff
--- a/examples/puredata/xtract~.c	Mon Dec 11 17:57:27 2006 +0000
+++ b/examples/puredata/xtract~.c	Tue Dec 12 21:47:42 2006 +0000
@@ -19,6 +19,7 @@
 /* calculates the spectral xtract of one frame, given peak frequency and amplitude to first and second inputs respectively */
 
 #include "m_pd.h"
+#include <math.h>
 
 #define XTRACT 
 #include "xtract/libxtract.h"
@@ -53,6 +54,9 @@
 
     if(return_code == FEATURE_NOT_IMPLEMENTED)
 	pd_error(x, "Feature not implemented");
+
+    /* set nan, inf or -inf to 0 */
+    result = (isinf(result) || isnan(result) ? 0 : result);
     
     outlet_float(x->x_obj.ob_outlet, result);
     return (w+4);
@@ -166,6 +170,7 @@
 	case  INHARMONICITY:
 	case  LOWEST_MATCH:
 	case  F0:
+	case  TONALITY:
 	    floatargs = 1;
 	    break;
 	case  SKEWNESS:
@@ -185,7 +190,6 @@
 	case  ZCR:
 	case  LOUDNESS:
 	case  FLATNESS:
-	case  TONALITY:
 	case  CREST:
 	case  NOISINESS:
 	case  RMS_AMPLITUDE:
@@ -218,7 +222,7 @@
 	x->argv = (xtract_mel_filter *)getbytes(x->memory.argv);
     }
     else if(x->feature == BARK_COEFFICIENTS){
-	x->memory.argv = (size_t)(sizeof(BARK_BANDS * sizeof(t_int)));
+	x->memory.argv = (size_t)(BARK_BANDS * sizeof(t_int));
         x->argv = (t_int *)getbytes(x->memory.argv);
     }
     else if (floatargs){