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 defined(__POWERPC__) && !(defined(__APPLE__) && defined(__MACH__)) 32 #include "config_maxmsp43.h" 33 #endif 34 35 #if defined(WIN32) && !defined(MINGW32) 36 #include "config_win32.h" 37 #endif 38 39 #if HAVE_STRING_H 40 #include <string.h> 41 #endif 42 43 #if HAVE_STDLIB_H 44 #include <stdlib.h> 45 #endif 46 47 #if HAVE_STDIO_H 48 #include <stdio.h> 49 #endif 50 51 #if HAVE_MATH_H 52 #include <math.h> 53 #endif 54 55 #if HAVE_ERRNO_H 56 #include <errno.h> 57 #endif 58 59 #if HAVE_STDARG_H 60 #include <stdarg.h> 61 #endif 62 63 #if HAVE_UNISTD_H 64 #include <unistd.h> 65 #endif 66 67 #if HAVE_FCNTL_H 68 #include <fcntl.h> 69 #endif 70 71 #if HAVE_SYS_MMAN_H 72 #include <sys/mman.h> 73 #endif 74 75 #if HAVE_SYS_TYPES_H 76 #include <sys/types.h> 77 #endif 78 79 #if HAVE_SYS_STAT_H 80 #include <sys/stat.h> 81 #endif 82 83 #if HAVE_SYS_TIME_H 84 #include <sys/time.h> 85 #endif 86 87 #if HAVE_SYS_SOCKET_H 88 #include <sys/socket.h> 89 #endif 90 91 #if HAVE_NETINET_IN_H 92 #include <netinet/in.h> 93 #endif 94 95 #if HAVE_NETINET_TCP_H 96 #include <netinet/tcp.h> 97 #endif 98 99 #if HAVE_ARPA_INET_H 100 #include <arpa/inet.h> 101 #endif 102 103 #if HAVE_LIMITS_H 104 #include <limits.h> 105 #endif 106 107 #if HAVE_PTHREAD_H 108 #include <pthread.h> 109 #endif 110 111 #if HAVE_IO_H 112 #include <io.h> 113 #endif 114 115 #if HAVE_WINDOWS_H 116 #include <winsock2.h> 117 #include <ws2tcpip.h> 118 #include <windows.h> 119 #endif 120 121 /* MinGW32 special defines */ 122 #ifdef MINGW32 123 124 #include <stdint.h> 125 #include <compat/msvc.h> 126 127 #define DSOUND_SUPPORT 1 128 #define WINMIDI_SUPPORT 1 129 #define STDIN_FILENO 0 130 #define STDOUT_FILENO 1 131 #define STDERR_FILENO 2 132 133 #endif 134 135 /* Darwin special defines (taken from config_macosx.h) */ 136 #ifdef DARWIN 137 #define MACINTOSH 138 #define __Types__ 139 #define WITHOUT_SERVER 1 140 #endif 141 142 143 #include "fluidsynth.h" 144 145 146 /*************************************************************** 147 * 148 * BASIC TYPES 149 */ 150 151 #if defined(WITH_FLOAT) 152 typedef float fluid_real_t; 153 #else 154 typedef double fluid_real_t; 155 #endif 156 157 158 #if defined(WIN32) 159 typedef SOCKET fluid_socket_t; 160 #else 161 typedef int fluid_socket_t; 162 #define INVALID_SOCKET -1 163 #endif 164 165 #if defined(SUPPORTS_VLA) 166 # define FLUID_DECLARE_VLA(_type, _name, _len) \ 167 _type _name[_len] 168 #else 169 # define FLUID_DECLARE_VLA(_type, _name, _len) \ 170 _type* _name = alloca(sizeof(_type) * (_len)) 171 #endif 172 173 174 /** Integer types */ 175 //typedef gint8 sint8; 176 typedef guint8 uint8; 177 //typedef gint16 sint16; 178 //typedef guint16 uint16; 179 typedef gint32 sint32; 180 typedef guint32 uint32; 181 //typedef gint64 sint64; 182 //typedef guint64 uint64; 183 184 185 /*************************************************************** 186 * 187 * FORWARD DECLARATIONS 188 */ 189 typedef struct _fluid_env_data_t fluid_env_data_t; 190 typedef struct _fluid_adriver_definition_t fluid_adriver_definition_t; 191 typedef struct _fluid_channel_t fluid_channel_t; 192 typedef struct _fluid_tuning_t fluid_tuning_t; 193 typedef struct _fluid_hashtable_t fluid_hashtable_t; 194 typedef struct _fluid_client_t fluid_client_t; 195 typedef struct _fluid_server_socket_t fluid_server_socket_t; 196 typedef struct _fluid_sample_timer_t fluid_sample_timer_t; 197 198 /*************************************************************** 199 * 200 * CONSTANTS 201 */ 202 203 #define FLUID_BUFSIZE 64 /**< FluidSynth internal buffer size (in samples) */ 204 #define FLUID_MAX_EVENTS_PER_BUFSIZE 1024 /**< Maximum queued MIDI events per #FLUID_BUFSIZE */ 205 #define FLUID_MAX_RETURN_EVENTS 1024 /**< Maximum queued synthesis thread return events */ 206 #define FLUID_MAX_EVENT_QUEUES 16 /**< Maximum number of unique threads queuing events */ 207 #define FLUID_DEFAULT_AUDIO_RT_PRIO 60 /**< Default setting for audio.realtime-prio */ 208 #define FLUID_DEFAULT_MIDI_RT_PRIO 50 /**< Default setting for midi.realtime-prio */ 209 210 #ifndef PI 211 #define PI 3.141592654 212 #endif 213 214 /*************************************************************** 215 * 216 * SYSTEM INTERFACE 217 */ 218 typedef FILE* fluid_file; 219 220 #define FLUID_MALLOC(_n) malloc(_n) 221 #define FLUID_REALLOC(_p,_n) realloc(_p,_n) 222 #define FLUID_NEW(_t) (_t*)malloc(sizeof(_t)) 223 #define FLUID_ARRAY(_t,_n) (_t*)malloc((_n)*sizeof(_t)) 224 #define FLUID_FREE(_p) free(_p) 225 #define FLUID_FOPEN(_f,_m) fopen(_f,_m) 226 #define FLUID_FCLOSE(_f) fclose(_f) 227 #define FLUID_FREAD(_p,_s,_n,_f) fread(_p,_s,_n,_f) 228 #define FLUID_FSEEK(_f,_n,_set) fseek(_f,_n,_set) 229 #define FLUID_MEMCPY(_dst,_src,_n) memcpy(_dst,_src,_n) 230 #define FLUID_MEMSET(_s,_c,_n) memset(_s,_c,_n) 231 #define FLUID_STRLEN(_s) strlen(_s) 232 #define FLUID_STRCMP(_s,_t) strcmp(_s,_t) 233 #define FLUID_STRNCMP(_s,_t,_n) strncmp(_s,_t,_n) 234 #define FLUID_STRCPY(_dst,_src) strcpy(_dst,_src) 235 #define FLUID_STRNCPY(_dst,_src,_n) strncpy(_dst,_src,_n) 236 #define FLUID_STRCHR(_s,_c) strchr(_s,_c) 237 #define FLUID_STRRCHR(_s,_c) strrchr(_s,_c) 238 #ifdef strdup 239 #define FLUID_STRDUP(s) strdup(s) 240 #else 241 #define FLUID_STRDUP(s) FLUID_STRCPY(FLUID_MALLOC(FLUID_STRLEN(s) + 1), s) 242 #endif 243 #define FLUID_SPRINTF sprintf 244 #define FLUID_FPRINTF fprintf 245 246 #define fluid_clip(_val, _min, _max) \ 247 { (_val) = ((_val) < (_min))? (_min) : (((_val) > (_max))? (_max) : (_val)); } 248 249 #if WITH_FTS 250 #define FLUID_PRINTF post 251 #define FLUID_FLUSH() 252 #else 253 #define FLUID_PRINTF printf 254 #define FLUID_FLUSH() fflush(stdout) 255 #endif 256 257 #define FLUID_LOG fluid_log 258 259 #ifndef M_PI 260 #define M_PI 3.1415926535897932384626433832795 261 #endif 262 263 264 #define FLUID_ASSERT(a,b) 265 #define FLUID_ASSERT_P(a,b) 266 267 char* fluid_error(void); 268 269 270 /* Internationalization */ 271 #define _(s) s 272 273 274 #endif /* _FLUIDSYNTH_PRIV_H */ 275