2 Copyright (C) 2003-2007 Paul Brossier
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Private include file
23 * This file is for inclusion from _within_ the library only.
29 /*********************
47 /* must be included before fftw3.h */
72 /* Memory management */
73 #define AUBIO_MALLOC(_n) malloc(_n)
74 #define AUBIO_REALLOC(_p,_n) realloc(_p,_n)
75 #define AUBIO_NEW(_t) (_t*)malloc(sizeof(_t))
76 #define AUBIO_ARRAY(_t,_n) (_t*)malloc((_n)*sizeof(_t))
77 #define AUBIO_MEMCPY(_dst,_src,_n) memcpy(_dst,_src,_n)
78 #define AUBIO_MEMSET(_dst,_src,_t) memset(_dst,_src,_t)
79 #define AUBIO_FREE(_p) free(_p)
83 #define AUBIO_FOPEN(_f,_m) fopen(_f,_m)
84 #define AUBIO_FCLOSE(_f) fclose(_f)
85 #define AUBIO_FREAD(_p,_s,_n,_f) fread(_p,_s,_n,_f)
86 #define AUBIO_FSEEK(_f,_n,_set) fseek(_f,_n,_set)
89 #define AUBIO_STRLEN(_s) strlen(_s)
90 #define AUBIO_STRCMP(_s,_t) strcmp(_s,_t)
91 #define AUBIO_STRNCMP(_s,_t,_n) strncmp(_s,_t,_n)
92 #define AUBIO_STRCPY(_dst,_src) strcpy(_dst,_src)
93 #define AUBIO_STRCHR(_s,_c) strchr(_s,_c)
95 #define AUBIO_STRDUP(s) strdup(s)
97 #define AUBIO_STRDUP(s) AUBIO_STRCPY(AUBIO_MALLOC(AUBIO_STRLEN(s) + 1), s)
101 /* Error reporting */
107 #ifdef HAVE_C99_VARARGS_MACROS
108 #define AUBIO_ERR(...) fprintf(stderr,__VA_ARGS__)
109 #define AUBIO_MSG(...) fprintf(stdout,__VA_ARGS__)
110 #define AUBIO_DBG(...) fprintf(stderr,__VA_ARGS__)
112 #define AUBIO_ERR(format, args...) fprintf(stderr, format , ##args)
113 #define AUBIO_MSG(format, args...) fprintf(stdout, format , ##args)
114 #define AUBIO_DBG(format, args...) fprintf(stderr, format , ##args)
117 #define AUBIO_QUIT(_s) exit(_s)
118 #define AUBIO_SPRINTF sprintf
122 #define TWO_PI (PI*2.)
124 /* aliases to math.h functions */
136 /* aliases to complex.h functions */
137 #if !defined(HAVE_COMPLEX_H) || defined(WIN32)
138 /* mingw32 does not know about c*f functions */
140 /** complex = CEXPC(complex) */
142 /** sample = ARGC(complex) */
144 /** sample = ABSC(complex) norm */
146 /** sample = REAL(complex) */
148 /** sample = IMAG(complex) */
151 /** sample = EXPC(complex) */
153 /** complex = CEXPC(complex) */
155 /** sample = ARGC(complex) */
157 /** sample = ABSC(complex) norm */
159 /** sample = REAL(complex) */
161 /** sample = IMAG(complex) */
165 /* handy shortcuts */
166 #define DB2LIN(g) (POW(10.0f,(g)*0.05f))
167 #define LIN2DB(v) (20.0f*LOG10(v))
168 #define SQR(_a) (_a*_a)
170 #define ELEM_SWAP(a,b) { register smpl_t t=(a);(a)=(b);(b)=t; }
172 #define UNUSED __attribute__((unused))
174 #endif/*_AUBIO_PRIV_H*/