diff options
author | Jamie Bullock <jamie@postlude.co.uk> | 2007-09-03 14:31:58 +0000 |
---|---|---|
committer | Jamie Bullock <jamie@postlude.co.uk> | 2007-09-03 14:31:58 +0000 |
commit | f8eed0713059b5c4e8e56ba98b8a33fe2a472d84 (patch) | |
tree | 3d77ea00cb55394fce82811fad29aaa258bdf776 /src/vector.c | |
parent | ff80e419ed5ce6291eefa90dc01b22939d15b0d0 (diff) | |
download | LibXtract-f8eed0713059b5c4e8e56ba98b8a33fe2a472d84.tar.gz LibXtract-f8eed0713059b5c4e8e56ba98b8a33fe2a472d84.tar.bz2 LibXtract-f8eed0713059b5c4e8e56ba98b8a33fe2a472d84.zip |
Checked ANSI C89 compliance (basically a few ifndefs for the C99 math functions: powf, roundf etc). Added a few PD examples/tests.
Diffstat (limited to 'src/vector.c')
-rw-r--r-- | src/vector.c | 11 |
1 files changed, 10 insertions, 1 deletions
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 <string.h> #include <stdlib.h> +#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 <fftw3.h> @@ -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; |