diff src/scalar.c @ 41:afb9e6fee244

Changes to xtract_inharmonicity - made parameters consistent with other xtractors that use peak spectrum. Fixed memory alloc bug in pd example.
author Jamie Bullock <jamie@postlude.co.uk>
date Mon, 11 Dec 2006 17:57:27 +0000
parents 0ea4d6430cfc
children 84e69b155098
line wrap: on
line diff
--- a/src/scalar.c	Mon Dec 11 11:22:13 2006 +0000
+++ b/src/scalar.c	Mon Dec 11 17:57:27 2006 +0000
@@ -316,19 +316,20 @@
 
 int xtract_inharmonicity(float *data, int N, void *argv, float *result){
 
-    int n = N;
+    int n = N >> 1;
     float num = 0.f, den = 0.f,
-	  *fund, *freq;
+	  fund, *freqs, *amps;
 
-    fund = *(float **)argv;
-    freq = fund+1;
+    fund = *(float *)argv;
+    freqs = data;
+    amps = data + n;
 
     while(n--){
-	num += abs(freq[n] - n * *fund) * SQ(data[n]);
-	den += SQ(data[n]);
+	num += abs(freqs[n] - n * fund) * SQ(amps[n]);
+	den += SQ(amps[n]);
     }
 
-    *result = (2 * num) / (*fund * den); 
+    *result = (2 * num) / (fund * den); 
 
     return SUCCESS;
 }