source: src/aubio_priv.h @ bd54912

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since bd54912 was b511fa9, checked in by Paul Brossier <piem@piem.org>, 15 years ago

replace FOO_SUPPORT with HAVE_FOO, use float for jack_process function prototype

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/*
2   Copyright (C) 2003-2007 Paul Brossier
3
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.
8
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.
13
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.
17   
18*/
19
20/** @file
21 * Private include file
22 *
23 * This file is for inclusion from _within_ the library only.
24 */
25
26#ifndef _AUBIO_PRIV_H
27#define _AUBIO_PRIV_H
28
29/*********************
30 *
31 * External includes
32 *
33 */
34
35#if 1 //HAVE_CONFIG_H
36#include "config.h"
37#endif
38
39#if HAVE_STDLIB_H
40#include <stdlib.h>
41#endif
42
43#if HAVE_STDIO_H
44#include <stdio.h>
45#endif
46
47/* must be included before fftw3.h */
48#if HAVE_COMPLEX_H
49#include <complex.h>
50#endif
51
52#if HAVE_FFTW3_H
53#include <fftw3.h>
54#endif
55
56#if HAVE_MATH_H
57#include <math.h>
58#endif
59
60#if HAVE_STRING_H
61#include <string.h>
62#endif
63
64#include "types.h"
65
66/****
67 *
68 * SYSTEM INTERFACE
69 *
70 */
71
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)
80
81
82/* file interface */
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)
87
88/* strings */
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)
94#ifdef strdup
95#define AUBIO_STRDUP(s)              strdup(s)
96#else
97#define AUBIO_STRDUP(s)              AUBIO_STRCPY(AUBIO_MALLOC(AUBIO_STRLEN(s) + 1), s)
98#endif
99
100
101/* Error reporting */
102typedef enum {
103  AUBIO_OK = 0,
104  AUBIO_FAIL = -1
105} aubio_status;
106
107#ifdef HAVE_C99_VARARGS_MACROS
108#define AUBIO_ERR(...)               fprintf(stderr, "AUBIO ERROR: " __VA_ARGS__)
109#define AUBIO_MSG(...)               fprintf(stdout, __VA_ARGS__)
110#define AUBIO_DBG(...)               fprintf(stderr, __VA_ARGS__)
111#define AUBIO_WRN(...)               fprintf(stderr, "AUBIO WARNING: " __VA_ARGS__)
112#else
113#define AUBIO_ERR(format, args...)   fprintf(stderr, "AUBIO ERROR: " format , ##args)
114#define AUBIO_MSG(format, args...)   fprintf(stdout, format , ##args)
115#define AUBIO_DBG(format, args...)   fprintf(stderr, format , ##args)
116#define AUBIO_WRN(...)               fprintf(stderr, "AUBIO WARNING: " format, ##args)
117#endif
118
119#define AUBIO_QUIT(_s)               exit(_s)
120#define AUBIO_SPRINTF                sprintf
121
122/* Libc shortcuts */
123#define PI         (M_PI)
124#define TWO_PI     (PI*2.)
125
126/* aliases to math.h functions */
127#if AUBIO_SINGLE_PRECISION
128#define EXP        expf
129#define COS        cosf
130#define SIN        sinf
131#define ABS        fabsf
132#define POW        powf
133#define SQRT       sqrtf
134#define LOG10      log10f
135#define LOG        logf
136#define FLOOR      floorf
137#define CEIL       ceilf
138#else
139#define EXP        exp
140#define COS        cos
141#define SIN        sin
142#define ABS        fabs
143#define POW        pow
144#define SQRT       sqrt
145#define LOG10      log10
146#define LOG        log
147#define FLOOR      floor
148#define CEIL       ceil
149#endif
150#define ROUND(x)   FLOOR(x+.5)
151
152/* aliases to complex.h functions */
153#if !defined(AUBIO_SINGLE_PRECISION) || !defined(HAVE_COMPLEX_H) || defined(WIN32)
154/* mingw32 does not know about c*f functions */
155#define EXPC      cexp
156/** complex = CEXPC(complex) */
157#define CEXPC     cexp
158/** sample = ARGC(complex) */
159#define ARGC      carg
160/** sample = ABSC(complex) norm */
161#define ABSC      cabs
162/** sample = REAL(complex) */
163#define REAL      creal
164/** sample = IMAG(complex) */
165#define IMAG      cimag
166#else
167/** sample = EXPC(complex) */
168#define EXPC      cexpf
169/** complex = CEXPC(complex) */
170#define CEXPC     cexp
171/** sample = ARGC(complex) */
172#define ARGC      cargf
173/** sample = ABSC(complex) norm */
174#define ABSC      cabsf
175/** sample = REAL(complex) */
176#define REAL      crealf
177/** sample = IMAG(complex) */
178#define IMAG      cimagf
179#endif
180
181/* handy shortcuts */
182#define DB2LIN(g) (POW(10.0f,(g)*0.05f))
183#define LIN2DB(v) (20.0f*LOG10(v))
184#define SQR(_a)   (_a*_a)
185
186#define MAX(a,b)  ( a > b ? a : b)
187#define MIN(a,b)  ( a < b ? a : b)
188
189#define ELEM_SWAP(a,b) { register smpl_t t=(a);(a)=(b);(b)=t; }
190
191#define ISDENORMAL(f) f < 1.e-37
192
193#define UNUSED __attribute__((unused))
194
195#endif/*_AUBIO_PRIV_H*/
Note: See TracBrowser for help on using the repository browser.