src/aubio_priv.h: fix typo in ROUND
[aubio.git] / src / aubio_priv.h
index ee3977f..cdb8269 100644 (file)
@@ -1,20 +1,20 @@
 /*
-        Copyright (C) 2003 Paul Brossier
-
-        This program is free software; you can redistribute it and/or modify
-        it under the terms of the GNU General Public License as published by
-        the Free Software Foundation; either version 2 of the License, or
-        (at your option) any later version.
-
-        This program is distributed in the hope that it will be useful,
-        but WITHOUT ANY WARRANTY; without even the implied warranty of
-        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-        GNU General Public License for more details.
-
-        You should have received a copy of the GNU General Public License
-        along with this program; if not, write to the Free Software
-        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-        
+   Copyright (C) 2003-2007 Paul Brossier
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   
 */
 
 /** @file
 #include <string.h>
 #endif
 
-#ifdef ALSA_SUPPORT
-#ifdef LADCCA_SUPPORT
-#include <ladcca/ladcca.h>
-extern cca_client_t * aubio_cca_client;
-#endif /* LADCCA_SUPPORT */
-#endif /* ALSA_SUPPORT */
-
-
 #include "types.h"
 
 /****
@@ -78,13 +70,13 @@ extern cca_client_t * aubio_cca_client;
  */
 
 /* 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_MEMCPY(_dst,_src,_n)     memcpy(_dst,_src,_n)
-#define AUBIO_MEMSET(_dst,_src,_t)     memset(_dst,_src,sizeof(_t))
-#define AUBIO_FREE(_p)                 free(_p)        
+#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_MEMCPY(_dst,_src,_n)   memcpy(_dst,_src,_n)
+#define AUBIO_MEMSET(_dst,_src,_t)   memset(_dst,_src,_t)
+#define AUBIO_FREE(_p)               free(_p)
 
 
 /* file interface */
@@ -125,4 +117,61 @@ typedef enum {
 #define AUBIO_QUIT(_s)               exit(_s)
 #define AUBIO_SPRINTF                sprintf
 
+/* Libc shortcuts */
+#define PI         (M_PI)
+#define TWO_PI     (PI*2.)
+
+/* aliases to math.h functions */
+#define EXP        expf
+#define COS        cosf
+#define SIN        sinf
+#define ABS        fabsf
+#define POW        powf
+#define SQRT       sqrtf
+#define LOG10      log10f
+#define LOG        logf
+#define FLOOR      floorf
+#define CEIL       ceilf
+#define ROUND(x)   FLOOR(x+.5)
+
+/* aliases to complex.h functions */
+#if !defined(HAVE_COMPLEX_H) || defined(WIN32)
+/* mingw32 does not know about c*f functions */
+#define EXPC      cexp
+/** complex = CEXPC(complex) */
+#define CEXPC     cexp
+/** sample = ARGC(complex) */
+#define ARGC      carg
+/** sample = ABSC(complex) norm */
+#define ABSC      cabs
+/** sample = REAL(complex) */
+#define REAL      creal
+/** sample = IMAG(complex) */
+#define IMAG      cimag
+#else
+/** sample = EXPC(complex) */
+#define EXPC      cexpf
+/** complex = CEXPC(complex) */
+#define CEXPC     cexp
+/** sample = ARGC(complex) */
+#define ARGC      cargf
+/** sample = ABSC(complex) norm */
+#define ABSC      cabsf
+/** sample = REAL(complex) */
+#define REAL      crealf
+/** sample = IMAG(complex) */
+#define IMAG      cimagf
+#endif
+
+/* handy shortcuts */
+#define DB2LIN(g) (POW(10.0f,(g)*0.05f))
+#define LIN2DB(v) (20.0f*LOG10(v))
+#define SQR(_a)   (_a*_a)
+
+#define ELEM_SWAP(a,b) { register smpl_t t=(a);(a)=(b);(b)=t; }
+
+#define ISDENORMAL(f) f < 1.e-37
+
+#define UNUSED __attribute__((unused))
+
 #endif/*_AUBIO_PRIV_H*/