From de66582f51c1e5ce57325d79b55292c64267f1ff Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Sun, 19 Aug 2007 16:54:25 +0000 Subject: 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!). --- src/scalar.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/scalar.c b/src/scalar.c index 1a52bd0..6732422 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -26,6 +26,7 @@ #include "math.h" #include #include +#include int xtract_mean(const float *data, const int N, const void *argv, float *result){ @@ -658,6 +659,8 @@ int xtract_hps(const float *data, const int N, const void *argv, float *result){ 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_hps(const float *data, const int N, const void *argv, float *result){ 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 @@ int xtract_failsafe_f0(const float *data, const int N, const void *argv, float * 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; -- cgit v1.2.3