74b9f4b9c688916166cc952cf5c0f397a6d585c6
[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 <winsock2.h>
109 #include <ws2tcpip.h>
110 #include <windows.h>
111 #endif
112
113 /* MinGW32 special defines */
114 #ifdef MINGW32
115
116 #include <stdint.h>
117 #define snprintf _snprintf
118 #define vsnprintf _vsnprintf
119
120 #define DSOUND_SUPPORT 1
121 #define WINMIDI_SUPPORT 1
122 #define STDIN_FILENO 0
123 #define STDOUT_FILENO 1
124 #define STDERR_FILENO 2
125
126 #endif
127
128 /* Darwin special defines (taken from config_macosx.h) */
129 #ifdef DARWIN
130 #define MACINTOSH
131 #define __Types__
132 #define WITHOUT_SERVER 1
133 #endif
134
135
136 #include "fluidsynth.h"
137
138
139 /***************************************************************
140  *
141  *         BASIC TYPES
142  */
143
144 #if defined(WITH_FLOAT)
145 typedef float fluid_real_t;
146 #else
147 typedef double fluid_real_t;
148 #endif
149
150
151 #if defined(WIN32)
152 typedef SOCKET fluid_socket_t;
153 #else
154 typedef int fluid_socket_t;
155 #define INVALID_SOCKET -1
156 #endif
157
158 #if defined(SUPPORTS_VLA)
159 #  define FLUID_DECLARE_VLA(_type, _name, _len) \
160      _type _name[_len]
161 #else
162 #  define FLUID_DECLARE_VLA(_type, _name, _len) \
163      _type* _name = g_newa(_type, (_len))
164 #endif
165
166
167 /** Integer types  */
168 //typedef gint8              sint8;
169 typedef guint8             uint8;
170 //typedef gint16             sint16;
171 //typedef guint16            uint16;
172 typedef gint32             sint32;
173 typedef guint32            uint32;
174 //typedef gint64             sint64;
175 //typedef guint64            uint64;
176
177
178 /***************************************************************
179  *
180  *       FORWARD DECLARATIONS
181  */
182 typedef struct _fluid_env_data_t fluid_env_data_t;
183 typedef struct _fluid_adriver_definition_t fluid_adriver_definition_t;
184 typedef struct _fluid_channel_t fluid_channel_t;
185 typedef struct _fluid_tuning_t fluid_tuning_t;
186 typedef struct _fluid_hashtable_t  fluid_hashtable_t;
187 typedef struct _fluid_client_t fluid_client_t;
188 typedef struct _fluid_server_socket_t fluid_server_socket_t;
189 typedef struct _fluid_sample_timer_t fluid_sample_timer_t;
190
191 /***************************************************************
192  *
193  *                      CONSTANTS
194  */
195
196 #define FLUID_BUFSIZE                64         /**< FluidSynth internal buffer size (in samples) */
197 #define FLUID_MAX_EVENTS_PER_BUFSIZE 1024       /**< Maximum queued MIDI events per #FLUID_BUFSIZE */
198 #define FLUID_MAX_RETURN_EVENTS      1024       /**< Maximum queued synthesis thread return events */
199 #define FLUID_MAX_EVENT_QUEUES       16         /**< Maximum number of unique threads queuing events */
200 #define FLUID_DEFAULT_AUDIO_RT_PRIO  60         /**< Default setting for audio.realtime-prio */
201 #define FLUID_DEFAULT_MIDI_RT_PRIO   50         /**< Default setting for midi.realtime-prio */
202
203 #ifndef PI
204 #define PI                          3.141592654
205 #endif
206
207 /***************************************************************
208  *
209  *                      SYSTEM INTERFACE
210  */
211 typedef FILE*  fluid_file;
212
213 #define FLUID_MALLOC(_n)             malloc(_n)
214 #define FLUID_REALLOC(_p,_n)         realloc(_p,_n)
215 #define FLUID_NEW(_t)                (_t*)malloc(sizeof(_t))
216 #define FLUID_ARRAY(_t,_n)           (_t*)malloc((_n)*sizeof(_t))
217 #define FLUID_FREE(_p)               free(_p)
218 #define FLUID_FOPEN(_f,_m)           fopen(_f,_m)
219 #define FLUID_FCLOSE(_f)             fclose(_f)
220 #define FLUID_FREAD(_p,_s,_n,_f)     fread(_p,_s,_n,_f)
221 #define FLUID_FSEEK(_f,_n,_set)      fseek(_f,_n,_set)
222 #define FLUID_MEMCPY(_dst,_src,_n)   memcpy(_dst,_src,_n)
223 #define FLUID_MEMSET(_s,_c,_n)       memset(_s,_c,_n)
224 #define FLUID_STRLEN(_s)             strlen(_s)
225 #define FLUID_STRCMP(_s,_t)          strcmp(_s,_t)
226 #define FLUID_STRNCMP(_s,_t,_n)      strncmp(_s,_t,_n)
227 #define FLUID_STRCPY(_dst,_src)      strcpy(_dst,_src)
228 #define FLUID_STRNCPY(_dst,_src,_n)  strncpy(_dst,_src,_n)
229 #define FLUID_STRCHR(_s,_c)          strchr(_s,_c)
230 #define FLUID_STRRCHR(_s,_c)         strrchr(_s,_c)
231 #ifdef strdup
232 #define FLUID_STRDUP(s)              strdup(s)
233 #else
234 #define FLUID_STRDUP(s)                     FLUID_STRCPY(FLUID_MALLOC(FLUID_STRLEN(s) + 1), s)
235 #endif
236 #define FLUID_SPRINTF                sprintf
237 #define FLUID_FPRINTF                fprintf
238
239 #define fluid_clip(_val, _min, _max) \
240 { (_val) = ((_val) < (_min))? (_min) : (((_val) > (_max))? (_max) : (_val)); }
241
242 #if WITH_FTS
243 #define FLUID_PRINTF                 post
244 #define FLUID_FLUSH()
245 #else
246 #define FLUID_PRINTF                 printf
247 #define FLUID_FLUSH()                fflush(stdout)
248 #endif
249
250 #define FLUID_LOG                    fluid_log
251
252 #ifndef M_PI
253 #define M_PI 3.1415926535897932384626433832795
254 #endif
255
256
257 #define FLUID_ASSERT(a,b)
258 #define FLUID_ASSERT_P(a,b)
259
260 char* fluid_error(void);
261
262
263 /* Internationalization */
264 #define _(s) s
265
266
267 #endif /* _FLUIDSYNTH_PRIV_H */