comparison aubioFullOSXUni/include/libsamplerate/common.h @ 0:572c856e38ac

Starting up openFrameworks project for audio time warping. The ofxFileReader goes in addons of your OF folder, the libraries and source (chromogram, fftw and source code src+ timewarp) are probably best kept in the repository, then dragged into the project afresh. That way, as we update the repository, the code that the openFrameworks project looks for will be updated.
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Tue, 17 May 2011 08:48:58 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:572c856e38ac
1 /*
2 ** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 /*
20 ** This code is part of Secret Rabibt Code aka libsamplerate. A commercial
21 ** use license for this code is available, please see:
22 ** http://www.mega-nerd.com/SRC/procedure.html
23 */
24
25 #ifndef COMMON_H_INCLUDED
26 #define COMMON_H_INCLUDED
27
28 #ifdef HAVE_STDINT_H
29 #include <stdint.h>
30 #elif (SIZEOF_INT == 4)
31 typedef int int32_t ;
32 #elif (SIZEOF_LONG == 4)
33 typedef long int32_t ;
34 #endif
35
36 #define SRC_MAX_RATIO 256
37 #define SRC_MIN_RATIO_DIFF (1e-20)
38
39 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
40 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
41
42 #define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
43 #define OFFSETOF(type,member) ((int) (&((type*) 0)->member))
44
45 #define MAKE_MAGIC(a,b,c,d,e,f) ((a) + ((b) << 4) + ((c) << 8) + ((d) << 12) + ((e) << 16) + ((f) << 20))
46
47
48 #include "samplerate.h"
49
50 enum
51 { SRC_FALSE = 0,
52 SRC_TRUE = 1,
53
54 SRC_MODE_PROCESS = 555,
55 SRC_MODE_CALLBACK = 556
56 } ;
57
58 enum
59 { SRC_ERR_NO_ERROR = 0,
60
61 SRC_ERR_MALLOC_FAILED,
62 SRC_ERR_BAD_STATE,
63 SRC_ERR_BAD_DATA,
64 SRC_ERR_BAD_DATA_PTR,
65 SRC_ERR_NO_PRIVATE,
66 SRC_ERR_BAD_SRC_RATIO,
67 SRC_ERR_BAD_PROC_PTR,
68 SRC_ERR_SHIFT_BITS,
69 SRC_ERR_FILTER_LEN,
70 SRC_ERR_BAD_CONVERTER,
71 SRC_ERR_BAD_CHANNEL_COUNT,
72 SRC_ERR_SINC_BAD_BUFFER_LEN,
73 SRC_ERR_SIZE_INCOMPATIBILITY,
74 SRC_ERR_BAD_PRIV_PTR,
75 SRC_ERR_BAD_SINC_STATE,
76 SRC_ERR_DATA_OVERLAP,
77 SRC_ERR_BAD_CALLBACK,
78 SRC_ERR_BAD_MODE,
79 SRC_ERR_NULL_CALLBACK,
80 SRC_ERR_NO_VARIABLE_RATIO,
81
82 /* This must be the last error number. */
83 SRC_ERR_MAX_ERROR
84 } ;
85
86 typedef struct SRC_PRIVATE_tag
87 { double last_ratio, last_position ;
88
89 int error ;
90 int channels ;
91
92 /* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */
93 int mode ;
94
95 /* Pointer to data to converter specific data. */
96 void *private_data ;
97
98 /* Varispeed process function. */
99 int (*vari_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ;
100
101 /* Constant speed process function. */
102 int (*const_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ;
103
104 /* State reset. */
105 void (*reset) (struct SRC_PRIVATE_tag *psrc) ;
106
107 /* Data specific to SRC_MODE_CALLBACK. */
108 src_callback_t callback_func ;
109 void *user_callback_data ;
110 long saved_frames ;
111 float *saved_data ;
112 } SRC_PRIVATE ;
113
114 /* In src_sinc.c */
115 const char* sinc_get_name (int src_enum) ;
116 const char* sinc_get_description (int src_enum) ;
117
118 int sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
119
120 /* In src_linear.c */
121 const char* linear_get_name (int src_enum) ;
122 const char* linear_get_description (int src_enum) ;
123
124 int linear_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
125
126 /* In src_zoh.c */
127 const char* zoh_get_name (int src_enum) ;
128 const char* zoh_get_description (int src_enum) ;
129
130 int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
131
132 /*----------------------------------------------------------
133 ** Common static inline functions.
134 */
135
136 static inline double
137 fmod_one (double x)
138 { double res ;
139
140 res = x - lrint (x) ;
141 if (res < 0.0)
142 return res + 1.0 ;
143
144 return res ;
145 } /* fmod_one */
146
147 #endif /* COMMON_H_INCLUDED */
148