X-Git-Url: https://git.aubio.org/?p=aubio.git;a=blobdiff_plain;f=src%2Faubio_priv.h;h=72ba091d8752f238239e8dbe5747b6e89f847803;hp=e4ebe5ad54e9858470aa06425c9c751c8af5853f;hb=cf19b8a8231deec641741007210ce57cd96332b5;hpb=76fc277f4bb19ac2291c1114a2b82b3f5183d9f9 diff --git a/src/aubio_priv.h b/src/aubio_priv.h index e4ebe5ad..72ba091d 100644 --- a/src/aubio_priv.h +++ b/src/aubio_priv.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2003-2009 Paul Brossier + Copyright (C) 2003-2015 Paul Brossier This file is part of aubio. @@ -20,56 +20,119 @@ /** @file * Private include file - * + * * This file is for inclusion from _within_ the library only. */ -#ifndef _AUBIO_PRIV_H -#define _AUBIO_PRIV_H +#ifndef AUBIO_PRIV_H +#define AUBIO_PRIV_H /********************* * - * External includes + * External includes * */ -#if 1 //HAVE_CONFIG_H #include "config.h" -#endif -#if HAVE_STDLIB_H +#ifdef HAVE_STDLIB_H #include #endif -#if HAVE_STDIO_H +#ifdef HAVE_STDIO_H #include #endif /* must be included before fftw3.h */ -#if HAVE_COMPLEX_H +#ifdef HAVE_COMPLEX_H #include #endif -#if HAVE_FFTW3 || HAVE_FFTW3F +#if defined(HAVE_FFTW3) || defined(HAVE_FFTW3F) #include #endif -#if HAVE_MATH_H +#ifdef HAVE_MATH_H #include #endif -#if HAVE_STRING_H +#ifdef HAVE_STRING_H #include #endif -#if HAVE_LIMITS_H +#ifdef HAVE_LIMITS_H #include // for CHAR_BIT, in C99 standard #endif +#ifdef HAVE_STDARG_H +#include +#endif + +#ifdef HAVE_ACCELERATE +#define HAVE_ATLAS 1 +#include +#elif defined(HAVE_ATLAS_CBLAS_H) +#define HAVE_ATLAS 1 +#include +#else +#undef HAVE_ATLAS +#endif + +#ifdef HAVE_ACCELERATE +#include +#ifndef HAVE_AUBIO_DOUBLE +#define aubio_vDSP_mmov vDSP_mmov +#define aubio_vDSP_vmul vDSP_vmul +#define aubio_vDSP_vfill vDSP_vfill +#define aubio_vDSP_meanv vDSP_meanv +#define aubio_vDSP_sve vDSP_sve +#define aubio_vDSP_maxv vDSP_maxv +#define aubio_vDSP_maxvi vDSP_maxvi +#define aubio_vDSP_minv vDSP_minv +#define aubio_vDSP_minvi vDSP_minvi +#define aubio_vDSP_dotpr vDSP_dotpr +#else /* HAVE_AUBIO_DOUBLE */ +#define aubio_vDSP_mmov vDSP_mmovD +#define aubio_vDSP_vmul vDSP_vmulD +#define aubio_vDSP_vfill vDSP_vfillD +#define aubio_vDSP_meanv vDSP_meanvD +#define aubio_vDSP_sve vDSP_sveD +#define aubio_vDSP_maxv vDSP_maxvD +#define aubio_vDSP_maxvi vDSP_maxviD +#define aubio_vDSP_minv vDSP_minvD +#define aubio_vDSP_minvi vDSP_minviD +#define aubio_vDSP_dotpr vDSP_dotprD +#endif /* HAVE_AUBIO_DOUBLE */ +#endif /* HAVE_ACCELERATE */ + +#ifdef HAVE_ATLAS +#ifndef HAVE_AUBIO_DOUBLE +#define aubio_catlas_set catlas_sset +#define aubio_cblas_copy cblas_scopy +#define aubio_cblas_swap cblas_sswap +#define aubio_cblas_dot cblas_sdot +#else /* HAVE_AUBIO_DOUBLE */ +#define aubio_catlas_set catlas_dset +#define aubio_cblas_copy cblas_dcopy +#define aubio_cblas_swap cblas_dswap +#define aubio_cblas_dot cblas_ddot +#endif /* HAVE_AUBIO_DOUBLE */ +#endif /* HAVE_ATLAS */ + +#if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) +#define HAVE_NOOPT 1 +#else +#undef HAVE_NOOPT +#endif + #include "types.h" +#define AUBIO_UNSTABLE 1 + +#include "mathutils.h" + /**** - * + * * SYSTEM INTERFACE * */ @@ -77,8 +140,8 @@ /* Memory management */ #define AUBIO_MALLOC(_n) malloc(_n) #define AUBIO_REALLOC(_p,_n) realloc(_p,_n) -#define AUBIO_NEW(_t) (_t*)malloc(sizeof(_t)) -#define AUBIO_ARRAY(_t,_n) (_t*)malloc((_n)*sizeof(_t)) +#define AUBIO_NEW(_t) (_t*)calloc(sizeof(_t), 1) +#define AUBIO_ARRAY(_t,_n) (_t*)calloc((_n)*sizeof(_t), 1) #define AUBIO_MEMCPY(_dst,_src,_n) memcpy(_dst,_src,_n) #define AUBIO_MEMSET(_dst,_src,_t) memset(_dst,_src,_t) #define AUBIO_FREE(_p) free(_p) @@ -106,19 +169,26 @@ /* Error reporting */ typedef enum { AUBIO_OK = 0, - AUBIO_FAIL = -1 + AUBIO_FAIL = 1 } aubio_status; +/* Logging */ + +#include "utils/log.h" + +/** internal logging function, defined in utils/log.c */ +uint_t aubio_log(sint_t level, const char_t *fmt, ...); + #ifdef HAVE_C99_VARARGS_MACROS -#define AUBIO_ERR(...) fprintf(stderr, "AUBIO ERROR: " __VA_ARGS__) -#define AUBIO_MSG(...) fprintf(stdout, __VA_ARGS__) -#define AUBIO_DBG(...) fprintf(stderr, __VA_ARGS__) -#define AUBIO_WRN(...) fprintf(stderr, "AUBIO WARNING: " __VA_ARGS__) +#define AUBIO_ERR(...) aubio_log(AUBIO_LOG_ERR, "AUBIO ERROR: " __VA_ARGS__) +#define AUBIO_MSG(...) aubio_log(AUBIO_LOG_MSG, __VA_ARGS__) +#define AUBIO_DBG(...) aubio_log(AUBIO_LOG_DBG, __VA_ARGS__) +#define AUBIO_WRN(...) aubio_log(AUBIO_LOG_WRN, "AUBIO WARNING: " __VA_ARGS__) #else -#define AUBIO_ERR(format, args...) fprintf(stderr, "AUBIO ERROR: " format , ##args) -#define AUBIO_MSG(format, args...) fprintf(stdout, format , ##args) -#define AUBIO_DBG(format, args...) fprintf(stderr, format , ##args) -#define AUBIO_WRN(...) fprintf(stderr, "AUBIO WARNING: " format, ##args) +#define AUBIO_ERR(format, args...) aubio_log(stderr, "AUBIO ERROR: " format , ##args) +#define AUBIO_MSG(format, args...) aubio_log(stdout, format , ##args) +#define AUBIO_DBG(format, args...) aubio_log(stderr, format , ##args) +#define AUBIO_WRN(format, args...) aubio_log(stderr, "AUBIO WARNING: " format, ##args) #endif #define AUBIO_ERROR AUBIO_ERR @@ -126,10 +196,21 @@ typedef enum { #define AUBIO_QUIT(_s) exit(_s) #define AUBIO_SPRINTF sprintf -/* Libc shortcuts */ +#define AUBIO_MAX_SAMPLERATE (192000*8) +#define AUBIO_MAX_CHANNELS 1024 + +/* pi and 2*pi */ +#ifndef M_PI +#define PI (3.14159265358979323846) +#else #define PI (M_PI) +#endif #define TWO_PI (PI*2.) +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + /* aliases to math.h functions */ #if !HAVE_AUBIO_DOUBLE #define EXP expf @@ -142,6 +223,7 @@ typedef enum { #define LOG logf #define FLOOR floorf #define CEIL ceilf +#define ATAN atanf #define ATAN2 atan2f #else #define EXP exp @@ -154,6 +236,7 @@ typedef enum { #define LOG log #define FLOOR floor #define CEIL ceil +#define ATAN atan #define ATAN2 atan2 #endif #define ROUND(x) FLOOR(x+.5) @@ -187,13 +270,22 @@ typedef enum { #define IMAG cimagf #endif +/* avoid unresolved symbol with msvc 9 */ +#if defined(_MSC_VER) && (_MSC_VER < 1900) +#define isnan _isnan +#endif + /* handy shortcuts */ #define DB2LIN(g) (POW(10.0,(g)*0.05f)) #define LIN2DB(v) (20.0*LOG10(v)) -#define SQR(_a) (_a*_a) +#define SQR(_a) ((_a)*(_a)) -#define MAX(a,b) ( a > b ? a : b) -#define MIN(a,b) ( a < b ? a : b) +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif /* MAX */ +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif /* MIN */ #define ELEM_SWAP(a,b) { register smpl_t t=(a);(a)=(b);(b)=t; } @@ -211,6 +303,19 @@ typedef enum { #define SAFE_LOG10(f) LOG10(CEIL_DENORMAL(f)) #define SAFE_LOG(f) LOG(CEIL_DENORMAL(f)) +/** silence unused parameter warning by adding an attribute */ +#if defined(__GNUC__) #define UNUSED __attribute__((unused)) +#else +#define UNUSED +#endif + +/* are we using gcc -std=c99 ? */ +#if defined(__STRICT_ANSI__) +#define strnlen(a,b) MIN(strlen(a),b) +#if !HAVE_AUBIO_DOUBLE +#define floorf floor +#endif +#endif /* __STRICT_ANSI__ */ -#endif/*_AUBIO_PRIV_H*/ +#endif /* AUBIO_PRIV_H */