From f8eed0713059b5c4e8e56ba98b8a33fe2a472d84 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Mon, 3 Sep 2007 14:31:58 +0000 Subject: Checked ANSI C89 compliance (basically a few ifndefs for the C99 math functions: powf, roundf etc). Added a few PD examples/tests. --- src/scalar.c | 8 ++++++++ src/vector.c | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/scalar.c b/src/scalar.c index ec22dd4..6270869 100644 --- a/src/scalar.c +++ b/src/scalar.c @@ -28,6 +28,14 @@ #include #include +#ifndef powf + #define powf pow +#endif + +#ifndef expf + #define expf exp +#endif + int xtract_mean(const float *data, const int N, const void *argv, float *result){ int n = N; diff --git a/src/vector.c b/src/vector.c index 77bad64..0df7048 100644 --- a/src/vector.c +++ b/src/vector.c @@ -27,6 +27,15 @@ #include #include +#ifndef roundf + float roundf(float f){ + if (f - (int)f >= 0.5) + return (float)((int)f + 1); + else + return (float)((int)f); + } +#endif + #ifdef XTRACT_FFT #include @@ -411,7 +420,7 @@ int xtract_harmonic_spectrum(const float *data, const int N, const void *argv, f while(n--){ if(freqs[n]){ ratio = freqs[n] / f0; - nearest = round(ratio); + nearest = roundf(ratio); distance = fabs(nearest - ratio); if(distance > threshold) result[n] = result[M + n] = 0.f; -- cgit v1.2.3