00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifdef USE_TIMIDITY_MIDI
00023
00024 #ifndef TIMIDITY_H_INCLUDED
00025 #define TIMIDITY_H_INCLUDED
00026
00027 #define NS_TIMIDITY Timidity_Pentagram
00028
00029 #ifdef NS_TIMIDITY
00030 namespace NS_TIMIDITY {
00031 #endif
00032
00033 struct MidiSong;
00034
00035
00036 extern char *Timidity_Error(void);
00037 extern void Timidity_SetVolume(int volume);
00038 extern int Timidity_PlaySome(void *stream, int samples);
00039 extern MidiSong *Timidity_LoadSong(char *midifile);
00040 extern void Timidity_Start(MidiSong *song);
00041 extern int Timidity_Active(void);
00042 extern void Timidity_Stop(void);
00043 extern void Timidity_FreeSong(MidiSong *song);
00044
00045
00046
00047
00048 #define PE_MONO 0x01
00049 #define PE_SIGNED 0x02
00050 #define PE_16BIT 0x04
00051 #define PE_ULAW 0x08
00052 #define PE_BYTESWAP 0x10
00053
00054 int Timidity_Init_Simple(int rate, int samples, sint32 encoding);
00055 void Timidity_DeInit();
00056 extern void Timidity_FinalInit(bool patches[128], bool drums[128]);
00057 extern void Timidity_PlayEvent(unsigned char status, int a, int b);
00058 extern void Timidity_GenerateSamples(void *stream, int samples);
00059
00060
00061
00062 #define SDL
00063 #if (defined(WIN32) || defined(_WIN32)) && !defined(__WIN32__)
00064 #define __WIN32__
00065 #endif
00066
00067
00068
00069
00070
00071 #define PATCH_EXT_LIST { ".pat", 0 }
00072
00073
00074 #define DEFAULT_PROGRAM 0
00075
00076
00077
00078
00079
00080
00081 #define DEFAULT_DRUMCHANNELS (1<<9)
00082
00083
00084
00085
00086 #define MIN_OUTPUT_RATE 4000
00087 #define MAX_OUTPUT_RATE 65000
00088
00089
00090 #define DEFAULT_AMPLIFICATION 70
00091
00092
00093
00094 #define DEFAULT_RATE 32000
00095 #define DEFAULT_VOICES 32
00096 #define MAX_VOICES 48
00097
00098
00099
00100
00101 #define CONTROLS_PER_SECOND 1000
00102
00103
00104
00105 #define LINEAR_INTERPOLATION
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 #define FRACTION_BITS 12
00133
00134
00135
00136
00137 #define ADJUST_SAMPLE_VOLUMES
00138
00139
00140
00141 #define MAX_DIE_TIME 20
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 #define PRECALC_LOOPS
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 #define INTEGER_BITS (32 - FRACTION_BITS)
00166 #define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS)
00167 #define FRACTION_MASK (~ INTEGER_MASK)
00168
00169
00170 #define MAX_CONTROL_RATIO 255
00171
00172
00173 #ifdef DEC
00174 #include <machine/endian.h>
00175 #endif
00176
00177 #ifdef linux
00178
00179
00180
00181
00182
00183
00184 #include <endian.h>
00185
00186
00187
00188
00189
00190
00191
00192 #undef LITTLE_ENDIAN
00193 #undef BIG_ENDIAN
00194
00195 # if __BYTE_ORDER == __LITTLE_ENDIAN
00196 # define LITTLE_ENDIAN
00197 # elif __BYTE_ORDER == __BIG_ENDIAN
00198 # define BIG_ENDIAN
00199 # else
00200 # error No byte sex defined
00201 # endif
00202 #endif
00203
00204
00205 #ifdef __WIN32__
00206 # define LITTLE_ENDIAN
00207 #endif
00208
00209 #ifdef i386
00210 #define LITTLE_ENDIAN
00211 #endif
00212
00213
00214
00215
00216 #define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
00217 # define XCHG_LONG(x) ((((x)&0xFF)<<24) | \
00218 (((x)&0xFF00)<<8) | \
00219 (((x)&0xFF0000)>>8) | \
00220 (((x)>>24)&0xFF))
00221
00222 #ifdef LITTLE_ENDIAN
00223 #define LE_SHORT(x) x
00224 #define LE_LONG(x) x
00225 #define BE_SHORT(x) XCHG_SHORT(x)
00226 #define BE_LONG(x) XCHG_LONG(x)
00227 #else
00228 #define BE_SHORT(x) x
00229 #define BE_LONG(x) x
00230 #define LE_SHORT(x) XCHG_SHORT(x)
00231 #define LE_LONG(x) XCHG_LONG(x)
00232 #endif
00233
00234 #define MAX_AMPLIFICATION 800
00235
00236
00237
00238 #define CONFIG_FILE "timidity.cfg"
00239 #ifndef DEFAULT_TIMIDITY_PATH
00240 #ifdef __WIN32__
00241 #define DEFAULT_TIMIDITY_PATH "\\TIMIDITY"
00242 #else
00243 #define DEFAULT_TIMIDITY_PATH "/usr/share/timidity"
00244 #endif
00245 #endif
00246
00247
00248 #define GUARD_BITS 3
00249 #define AMP_BITS (15-GUARD_BITS)
00250
00251 #ifdef LOOKUP_HACK
00252 typedef sint8 sample_t;
00253 typedef uint8 final_volume_t;
00254 # define FINAL_VOLUME(v) (~_l2u[v])
00255 # define MIXUP_SHIFT 5
00256 # define MAX_AMP_VALUE 4095
00257 #else
00258 typedef sint16 sample_t;
00259 typedef sint32 final_volume_t;
00260 # define FINAL_VOLUME(v) (v)
00261 # define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1)
00262 #endif
00263
00264 #ifdef USE_LDEXP
00265 # define FSCALE(a,b) ldexp((a),(b))
00266 # define FSCALENEG(a,b) ldexp((a),-(b))
00267 #else
00268 # define FSCALE(a,b) (float)((a) * (double)(1<<(b)))
00269 # define FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b))))
00270 #endif
00271
00272
00273 #define SWEEP_TUNING 38
00274 #define VIBRATO_AMPLITUDE_TUNING 1.0L
00275 #define VIBRATO_RATE_TUNING 38
00276 #define TREMOLO_AMPLITUDE_TUNING 1.0L
00277 #define TREMOLO_RATE_TUNING 38
00278
00279 #define SWEEP_SHIFT 16
00280 #define RATE_SHIFT 5
00281
00282 #define VIBRATO_SAMPLE_INCREMENTS 32
00283
00284 #ifndef PI
00285 #define PI 3.14159265358979323846
00286 #endif
00287
00288
00289 #ifdef __WIN32__
00290 # define PATH_SEP '\\'
00291 # define PATH_STRING "\\"
00292 #else
00293 # define PATH_SEP '/'
00294 # define PATH_STRING "/"
00295 #endif
00296
00297 #ifdef NS_TIMIDITY
00298 };
00299 #endif
00300
00301 #endif
00302
00303 #endif //USE_TIMIDITY_MIDI