b01618df26e7bd6c59f6ce1701efb0c8dceb7478
[ardour.git] / libs / fluidsynth / src / fluidsynth_priv.h
1 /* FluidSynth - A Software Synthesizer
2  *
3  * Copyright (C) 2003  Peter Hanappe and others.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public License
7  * as published by the Free Software Foundation; either version 2 of
8  * the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA
19  */
20
21
22 #ifndef _FLUIDSYNTH_PRIV_H
23 #define _FLUIDSYNTH_PRIV_H
24
25 #include <glib.h>
26
27 #if HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #if HAVE_STRING_H
32 #include <string.h>
33 #endif
34
35 #if HAVE_STDLIB_H
36 #include <stdlib.h>
37 #endif
38
39 #if HAVE_STDIO_H
40 #include <stdio.h>
41 #endif
42
43 #if HAVE_MATH_H
44 #include <math.h>
45 #endif
46
47 #if HAVE_ERRNO_H
48 #include <errno.h>
49 #endif
50
51 #if HAVE_STDARG_H
52 #include <stdarg.h>
53 #endif
54
55 #if HAVE_UNISTD_H
56 #include <unistd.h>
57 #endif
58
59 #if HAVE_FCNTL_H
60 #include <fcntl.h>
61 #endif
62
63 #if HAVE_SYS_MMAN_H
64 #include <sys/mman.h>
65 #endif
66
67 #if HAVE_SYS_TYPES_H
68 #include <sys/types.h>
69 #endif
70
71 #if HAVE_SYS_STAT_H
72 #include <sys/stat.h>
73 #endif
74
75 #if HAVE_SYS_TIME_H
76 #include <sys/time.h>
77 #endif
78
79 #if HAVE_SYS_SOCKET_H
80 #include <sys/socket.h>
81 #endif
82
83 #if HAVE_NETINET_IN_H
84 #include <netinet/in.h>
85 #endif
86
87 #if HAVE_NETINET_TCP_H
88 #include <netinet/tcp.h>
89 #endif
90
91 #if HAVE_ARPA_INET_H
92 #include <arpa/inet.h>
93 #endif
94
95 #if HAVE_LIMITS_H
96 #include <limits.h>
97 #endif
98
99 #if HAVE_PTHREAD_H
100 #include <pthread.h>
101 #endif
102
103 #if HAVE_IO_H
104 #include <io.h>
105 #endif
106
107 #if HAVE_WINDOWS_H
108 #include <windows.h>
109 #endif
110
111 /* MinGW32 special defines */
112 #ifdef MINGW32
113
114 #include <stdint.h>
115 #define snprintf _snprintf
116 #define vsnprintf _vsnprintf
117
118 #define DSOUND_SUPPORT 1
119 #define WINMIDI_SUPPORT 1
120 #define STDIN_FILENO 0
121 #define STDOUT_FILENO 1
122 #define STDERR_FILENO 2
123
124 #elif defined _MSC_VER
125
126 #define STDIN_FILENO  _fileno(stdin)
127 #define STDOUT_FILENO _fileno(stdout)
128 #define STDERR_FILENO _fileno(stderr)
129
130 #endif
131
132 /* Darwin special defines (taken from config_macosx.h) */
133 #ifdef DARWIN
134 #define MACINTOSH
135 #define __Types__
136 #define WITHOUT_SERVER 1
137 #endif
138
139
140 #include "fluidsynth.h"
141
142
143 /***************************************************************
144  *
145  *         BASIC TYPES
146  */
147
148 #if defined(WITH_FLOAT)
149 typedef float fluid_real_t;
150 #else
151 typedef double fluid_real_t;
152 #endif
153
154
155 #if defined(WIN32)
156 typedef SOCKET fluid_socket_t;
157 #else
158 typedef int fluid_socket_t;
159 #define INVALID_SOCKET -1
160 #endif
161
162 #if defined(SUPPORTS_VLA)
163 #  define FLUID_DECLARE_VLA(_type, _name, _len) \
164      _type _name[_len]
165 #else
166 #  define FLUID_DECLARE_VLA(_type, _name, _len) \
167      _type* _name = g_newa(_type, (_len))
168 #endif
169
170
171 /** Integer types  */
172 //typedef gint8              sint8;
173 typedef guint8             uint8;
174 //typedef gint16             sint16;
175 //typedef guint16            uint16;
176 typedef gint32             sint32;
177 typedef guint32            uint32;
178 //typedef gint64             sint64;
179 //typedef guint64            uint64;
180
181
182 /***************************************************************
183  *
184  *       FORWARD DECLARATIONS
185  */
186 typedef struct _fluid_env_data_t fluid_env_data_t;
187 typedef struct _fluid_adriver_definition_t fluid_adriver_definition_t;
188 typedef struct _fluid_channel_t fluid_channel_t;
189 typedef struct _fluid_tuning_t fluid_tuning_t;
190 typedef struct _fluid_hashtable_t  fluid_hashtable_t;
191 typedef struct _fluid_client_t fluid_client_t;
192 typedef struct _fluid_server_socket_t fluid_server_socket_t;
193 typedef struct _fluid_sample_timer_t fluid_sample_timer_t;
194
195 /***************************************************************
196  *
197  *                      CONSTANTS
198  */
199
200 #define FLUID_BUFSIZE                64         /**< FluidSynth internal buffer size (in samples) */
201 #define FLUID_MAX_EVENTS_PER_BUFSIZE 1024       /**< Maximum queued MIDI events per #FLUID_BUFSIZE */
202 #define FLUID_MAX_RETURN_EVENTS      1024       /**< Maximum queued synthesis thread return events */
203 #define FLUID_MAX_EVENT_QUEUES       16         /**< Maximum number of unique threads queuing events */
204 #define FLUID_DEFAULT_AUDIO_RT_PRIO  60         /**< Default setting for audio.realtime-prio */
205 #define FLUID_DEFAULT_MIDI_RT_PRIO   50         /**< Default setting for midi.realtime-prio */
206
207 #ifndef PI
208 #define PI                          3.141592654
209 #endif
210
211 /***************************************************************
212  *
213  *                      SYSTEM INTERFACE
214  */
215 typedef FILE*  fluid_file;
216
217 #define FLUID_MALLOC(_n)             malloc(_n)
218 #define FLUID_REALLOC(_p,_n)         realloc(_p,_n)
219 #define FLUID_NEW(_t)                (_t*)malloc(sizeof(_t))
220 #define FLUID_ARRAY(_t,_n)           (_t*)malloc((_n)*sizeof(_t))
221 #define FLUID_FREE(_p)               free(_p)
222 #define FLUID_FOPEN(_f,_m)           fopen(_f,_m)
223 #define FLUID_FCLOSE(_f)             fclose(_f)
224 #define FLUID_FREAD(_p,_s,_n,_f)     fread(_p,_s,_n,_f)
225 #define FLUID_FSEEK(_f,_n,_set)      fseek(_f,_n,_set)
226 #define FLUID_MEMCPY(_dst,_src,_n)   memcpy(_dst,_src,_n)
227 #define FLUID_MEMSET(_s,_c,_n)       memset(_s,_c,_n)
228 #define FLUID_STRLEN(_s)             strlen(_s)
229 #define FLUID_STRCMP(_s,_t)          strcmp(_s,_t)
230 #define FLUID_STRNCMP(_s,_t,_n)      strncmp(_s,_t,_n)
231 #define FLUID_STRCPY(_dst,_src)      strcpy(_dst,_src)
232 #define FLUID_STRNCPY(_dst,_src,_n)  strncpy(_dst,_src,_n)
233 #define FLUID_STRCHR(_s,_c)          strchr(_s,_c)
234 #define FLUID_STRRCHR(_s,_c)         strrchr(_s,_c)
235 #ifdef strdup
236 #define FLUID_STRDUP(s)              strdup(s)
237 #else
238 #define FLUID_STRDUP(s)                     FLUID_STRCPY(FLUID_MALLOC(FLUID_STRLEN(s) + 1), s)
239 #endif
240 #define FLUID_SPRINTF                sprintf
241 #define FLUID_FPRINTF                fprintf
242
243 #define fluid_clip(_val, _min, _max) \
244 { (_val) = ((_val) < (_min))? (_min) : (((_val) > (_max))? (_max) : (_val)); }
245
246 #if WITH_FTS
247 #define FLUID_PRINTF                 post
248 #define FLUID_FLUSH()
249 #else
250 #define FLUID_PRINTF                 printf
251 #define FLUID_FLUSH()                fflush(stdout)
252 #endif
253
254 #define FLUID_LOG                    fluid_log
255
256 #ifndef M_PI
257 #define M_PI 3.1415926535897932384626433832795
258 #endif
259
260
261 #define FLUID_ASSERT(a,b)
262 #define FLUID_ASSERT_P(a,b)
263
264 char* fluid_error(void);
265
266
267 /* Internationalization */
268 #define _(s) s
269
270
271 #endif /* _FLUIDSYNTH_PRIV_H */