andrew@0: /* andrew@0: Copyright (C) 2003 Paul Brossier andrew@0: andrew@0: This program is free software; you can redistribute it and/or modify andrew@0: it under the terms of the GNU General Public License as published by andrew@0: the Free Software Foundation; either version 2 of the License, or andrew@0: (at your option) any later version. andrew@0: andrew@0: This program is distributed in the hope that it will be useful, andrew@0: but WITHOUT ANY WARRANTY; without even the implied warranty of andrew@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrew@0: GNU General Public License for more details. andrew@0: andrew@0: You should have received a copy of the GNU General Public License andrew@0: along with this program; if not, write to the Free Software andrew@0: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. andrew@0: andrew@0: */ andrew@0: andrew@0: /** @file andrew@0: * Private include file andrew@0: * andrew@0: * This file is for inclusion from _within_ the library only. andrew@0: */ andrew@0: andrew@0: #ifndef _AUBIO_PRIV_H andrew@0: #define _AUBIO_PRIV_H andrew@0: andrew@0: /********************* andrew@0: * andrew@0: * External includes andrew@0: * andrew@0: */ andrew@0: andrew@0: #if HAVE_CONFIG_H andrew@0: #include "config.h" andrew@0: #endif andrew@0: andrew@0: #if HAVE_STDLIB_H andrew@0: #include andrew@0: #endif andrew@0: andrew@0: #if HAVE_STDIO_H andrew@0: #include andrew@0: #endif andrew@0: andrew@0: /* must be included before fftw3.h */ andrew@0: #if HAVE_COMPLEX_H andrew@0: #include andrew@0: #endif andrew@0: andrew@0: #if HAVE_FFTW3_H andrew@0: #include andrew@0: #endif andrew@0: andrew@0: #if HAVE_MATH_H andrew@0: #include andrew@0: #endif andrew@0: andrew@0: #if HAVE_STRINGS_H andrew@0: #include andrew@0: #endif andrew@0: andrew@0: #include "types.h" andrew@0: andrew@0: /**** andrew@0: * andrew@0: * SYSTEM INTERFACE andrew@0: * andrew@0: */ andrew@0: andrew@0: /* Memory management */ andrew@0: #define AUBIO_MALLOC(_n) malloc(_n) andrew@0: #define AUBIO_REALLOC(_p,_n) realloc(_p,_n) andrew@0: #define AUBIO_NEW(_t) (_t*)malloc(sizeof(_t)) andrew@0: #define AUBIO_ARRAY(_t,_n) (_t*)malloc((_n)*sizeof(_t)) andrew@0: #define AUBIO_MEMCPY(_dst,_src,_n) memcpy(_dst,_src,_n) andrew@0: #define AUBIO_MEMSET(_dst,_src,_t) memset(_dst,_src,_t) andrew@0: #define AUBIO_FREE(_p) free(_p) andrew@0: andrew@0: andrew@0: /* file interface */ andrew@0: #define AUBIO_FOPEN(_f,_m) fopen(_f,_m) andrew@0: #define AUBIO_FCLOSE(_f) fclose(_f) andrew@0: #define AUBIO_FREAD(_p,_s,_n,_f) fread(_p,_s,_n,_f) andrew@0: #define AUBIO_FSEEK(_f,_n,_set) fseek(_f,_n,_set) andrew@0: andrew@0: /* strings */ andrew@0: #define AUBIO_STRLEN(_s) strlen(_s) andrew@0: #define AUBIO_STRCMP(_s,_t) strcmp(_s,_t) andrew@0: #define AUBIO_STRNCMP(_s,_t,_n) strncmp(_s,_t,_n) andrew@0: #define AUBIO_STRCPY(_dst,_src) strcpy(_dst,_src) andrew@0: #define AUBIO_STRCHR(_s,_c) strchr(_s,_c) andrew@0: #ifdef strdup andrew@0: #define AUBIO_STRDUP(s) strdup(s) andrew@0: #else andrew@0: #define AUBIO_STRDUP(s) AUBIO_STRCPY(AUBIO_MALLOC(AUBIO_STRLEN(s) + 1), s) andrew@0: #endif andrew@0: andrew@0: andrew@0: /* Error reporting */ andrew@0: typedef enum { andrew@0: AUBIO_OK = 0, andrew@0: AUBIO_FAIL = -1 andrew@0: } aubio_status; andrew@0: andrew@0: #ifdef HAVE_C99_VARARGS_MACROS andrew@0: #define AUBIO_ERR(...) fprintf(stderr,__VA_ARGS__) andrew@0: #define AUBIO_MSG(...) fprintf(stdout,__VA_ARGS__) andrew@0: #define AUBIO_DBG(...) fprintf(stderr,__VA_ARGS__) andrew@0: #else andrew@0: #define AUBIO_ERR(format, args...) fprintf(stderr, format , ##args) andrew@0: #define AUBIO_MSG(format, args...) fprintf(stdout, format , ##args) andrew@0: #define AUBIO_DBG(format, args...) fprintf(stderr, format , ##args) andrew@0: #endif andrew@0: andrew@0: #define AUBIO_QUIT(_s) exit(_s) andrew@0: #define AUBIO_SPRINTF sprintf andrew@0: andrew@0: /* Libc shortcuts */ andrew@0: #define PI (M_PI) andrew@0: #define TWO_PI (PI*2.) andrew@0: andrew@0: /* aliases to math.h functions */ andrew@0: #define EXP expf andrew@0: #define COS cosf andrew@0: #define SIN sinf andrew@0: #define ABS fabsf andrew@0: #define POW powf andrew@0: #define SQRT sqrtf andrew@0: #define LOG10 log10f andrew@0: #define LOG logf andrew@0: #define FLOOR floorf andrew@0: #define TRUNC truncf andrew@0: andrew@0: /* aliases to complex.h functions */ andrew@0: #if !defined(HAVE_COMPLEX_H) || defined(WIN32) andrew@0: /* mingw32 does not know about c*f functions */ andrew@0: #define EXPC cexp andrew@0: /** complex = CEXPC(complex) */ andrew@0: #define CEXPC cexp andrew@0: /** sample = ARGC(complex) */ andrew@0: #define ARGC carg andrew@0: /** sample = ABSC(complex) norm */ andrew@0: #define ABSC cabs andrew@0: /** sample = REAL(complex) */ andrew@0: #define REAL creal andrew@0: /** sample = IMAG(complex) */ andrew@0: #define IMAG cimag andrew@0: #else andrew@0: /** sample = EXPC(complex) */ andrew@0: #define EXPC cexpf andrew@0: /** complex = CEXPC(complex) */ andrew@0: #define CEXPC cexp andrew@0: /** sample = ARGC(complex) */ andrew@0: #define ARGC cargf andrew@0: /** sample = ABSC(complex) norm */ andrew@0: #define ABSC cabsf andrew@0: /** sample = REAL(complex) */ andrew@0: #define REAL crealf andrew@0: /** sample = IMAG(complex) */ andrew@0: #define IMAG cimagf andrew@0: #endif andrew@0: andrew@0: /* handy shortcuts */ andrew@0: #define DB2LIN(g) (POW(10.0f,(g)*0.05f)) andrew@0: #define LIN2DB(v) (20.0f*LOG10(v)) andrew@0: #define SQR(_a) (_a*_a) andrew@0: andrew@0: #define ELEM_SWAP(a,b) { register smpl_t t=(a);(a)=(b);(b)=t; } andrew@0: andrew@0: #define UNUSED __attribute__((unused)) andrew@0: andrew@0: #endif/*_AUBIO_PRIV_H*/