aboutsummaryrefslogtreecommitdiff
path: root/src/scalar.c
diff options
context:
space:
mode:
authorJamie Bullock <jamie@postlude.co.uk>2007-08-19 16:54:25 +0000
committerJamie Bullock <jamie@postlude.co.uk>2007-08-19 16:54:25 +0000
commitde66582f51c1e5ce57325d79b55292c64267f1ff (patch)
tree56fbfceb2a45a64d4f7e5c7191cbf8e0b8e1d3e1 /src/scalar.c
parenta6c2d64b740008f10ddfa35143632669e0db1a16 (diff)
downloadLibXtract-de66582f51c1e5ce57325d79b55292c64267f1ff.tar.gz
LibXtract-de66582f51c1e5ce57325d79b55292c64267f1ff.tar.bz2
LibXtract-de66582f51c1e5ce57325d79b55292c64267f1ff.zip
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!).
Diffstat (limited to 'src/scalar.c')
-rw-r--r--src/scalar.c10
1 files changed, 9 insertions, 1 deletions
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 <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 @@ 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;