diff src/scalar.c @ 78:afb298ce1b4d

Fixes for MSP example, and changed the fundamental estimators so that if they don't get a samplerate 44100 is assumed (I'm not sure if this is a good idea!).
author Jamie Bullock <jamie@postlude.co.uk>
date Sun, 19 Aug 2007 16:54:25 +0000
parents f926b6b299e7
children 5fadbacdb2a7
line wrap: on
line diff
--- a/src/scalar.c	Tue Jul 31 20:44:17 2007 +0000
+++ b/src/scalar.c	Sun Aug 19 16:54:25 2007 +0000
@@ -26,6 +26,7 @@
 #include "math.h"
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>
 
 int xtract_mean(const float *data, const int N, const void *argv, float *result){
 
@@ -658,6 +659,8 @@
 	  largest1_lwr, peak, ratio1, sr;
 
     sr = *(float*)argv;
+    if(sr == 0)
+	sr = 44100.f;
 
     coeffs2 = (float *)malloc(N * sizeof(float));
     coeffs3 = (float *)malloc(N * sizeof(float));
@@ -715,13 +718,16 @@
 
 int xtract_f0(const float *data, const int N, const void *argv, float *result){
 
-    int M, sr, tau, n;
+    int M, tau, n;
+    float sr;
     size_t bytes;
     float f0, err_tau_1, err_tau_x, array_max, 
 	  threshold_peak, threshold_centre,
 	  *input;
 
     sr = *(float *)argv;
+    if(sr == 0)
+	sr = 44100.f;
 
     input = (float *)malloc(bytes = N * sizeof(float));
     input = memcpy(input, data, bytes);
@@ -793,6 +799,8 @@
     if(return_code == XTRACT_NO_RESULT){
 
 	sr = *(float *)argv;
+	if(sr == 0)
+	    sr = 44100.f;
 	spectrum = (float *)malloc(N * sizeof(float));
 	peaks = (float *)malloc(N * sizeof(float));
 	argf[0] = sr;