-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.h
423 lines (356 loc) · 12 KB
/
config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
/*
$Id$
TiMidity -- Experimental MIDI to WAVE converter
Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef ADAGIO
#include "adagio.h"
#include "allphase.h"
#endif /* ADAGIO */
#ifdef KMIDI
#include "../config.h"
#else
#include "../../config.h"
/* if above referenced file does not exist, use something like:
#define HAVE_STRING_H
#define HAVE_SLANG_H
#define HAVE_USLEEP
*/
#endif
#ifndef HAVE_STRING_H
#define NO_STRING_H
#endif
#ifndef TIMID_DIR
#ifdef DEFAULT_PATH
#define TIMID_DIR DEFAULT_PATH
#else
#define TIMID_DIR "/usr/local/lib/timidity"
#endif
#endif
/* Enable extensions taken from TiMidity++ */
#define tplus
/* Enable Nicolas Witczak's effects processing */
#define CHANNEL_EFFECT
/* Filename extension, followed by command to run decompressor so that
output is written to stdout. Terminate the list with a 0.
Any file with a name ending in one of these strings will be run
through the corresponding decompressor. If you don't like this
behavior, you can undefine DECOMPRESSOR_LIST to disable automatic
decompression entirely.
This is currently ignored for Win32. */
#define DECOMPRESSOR_LIST { \
".gz", "gunzip -c %s", \
".bz2", "bzip2 -cd %s", \
".Z", "zcat %s", \
".zip", "unzip -p %s", \
".lha", "lha -pq %s", \
".lzh", "lha -pq %s", \
".shn", "shorten -x %s -", \
".wav", "wav2pat %s", \
0 }
/* When a patch file can't be opened, one of these extensions is
appended to the filename and the open is tried again.
This is ignored for Win32, which uses only ".pat" (see the bottom
of this file if you need to change this.) */
#define PATCH_EXT_LIST { \
".pat", \
".shn", ".pat.shn", \
".gz", ".pat.gz", \
0 }
/* Acoustic Grand Piano seems to be the usual default instrument. */
#define DEFAULT_PROGRAM 0
/* 9 here is MIDI channel 10, which is the standard percussion channel.
Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too.
On the other hand, some files know that 16 is not a drum channel and
try to play music on it. This is now a runtime option, so this isn't
a critical choice anymore. */
#define DEFAULT_DRUMCHANNELS (1<<9)
/*#define DEFAULT_DRUMCHANNELS ((1<<9) | (1<<15))*/
/* type of floating point number */
typedef double FLOAT_T;
/* typedef float FLOAT_T; */
/* A somewhat arbitrary frequency range. The low end of this will
sound terrible as no lowpass filtering is performed on most
instruments before resampling. */
#define MIN_OUTPUT_RATE 4000
#define MAX_OUTPUT_RATE 65000
/* In percent. */
#ifndef DEFAULT_AMPLIFICATION
#define DEFAULT_AMPLIFICATION 70
#endif
/* Default sampling rate, default polyphony, and maximum polyphony.
All but the last can be overridden from the command line. */
#ifndef DEFAULT_RATE
/*#define DEFAULT_RATE 32000*/
#define DEFAULT_RATE 44100
#endif
#ifndef DEFAULT_VOICES
#ifdef ADAGIO
#define DEFAULT_VOICES DEFAULT_DSPVOICES
#else
#define DEFAULT_VOICES 64
#endif
#endif
#ifndef MAX_VOICES
#ifdef ADAGIO
/* Should check this. MAX_DSPVOICES should be the
number of Timidity "channels", but the maximum number
of polyphonic voices playing simultaneously should be
larger. Now the two maxima are treated the same.
*/
#define MAX_VOICES MAX_DSPVOICES
#else
#define MAX_VOICES 128
#endif
#endif
/* The size of the internal buffer is 2^AUDIO_BUFFER_BITS samples.
This determines maximum number of samples ever computed in a row.
For Linux, FreeBSD and BSD/OS users:
This also specifies the size of the buffer fragment. A smaller
fragment gives a faster response in interactive mode -- 10 or 11 is
probably a good number. Unfortunately some sound cards emit a click
when switching DMA buffers. If this happens to you, try increasing
this number to reduce the frequency of the clicks.
For other systems:
You should probably use a larger number for improved performance.
*/
#ifdef __WIN32__
#define AUDIO_BUFFER_BITS 12
#else
/** #define AUDIO_BUFFER_BITS 11 **/
#define AUDIO_BUFFER_BITS 10
#endif
/* 1000 here will give a control ratio of 22:1 with 22 kHz output.
Higher CONTROLS_PER_SECOND values allow more accurate rendering
of envelopes and tremolo. The cost is CPU time. */
/*#define CONTROLS_PER_SECOND 1000*/
#define CONTROLS_PER_SECOND 2000
/* Make envelopes twice as fast. Saves ~20% CPU time (notes decay
faster) and sounds more like a GUS. There is now a command line
option to toggle this as well. */
/*#define FAST_DECAY*/
/* How many bits to use for the fractional part of sample positions.
This affects tonal accuracy. The entire position counter must fit
in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of
a sample is 1048576 samples (2 megabytes in memory). The GUS gets
by with just 9 bits and a little help from its friends...
"The GUS does not SUCK!!!" -- a happy user :) */
/* #define FRACTION_BITS 12 */
#define FRACTION_BITS 13
/* For some reason the sample volume is always set to maximum in all
patch files. Define this for a crude adjustment that may help
equalize instrument volumes. */
#define ADJUST_SAMPLE_VOLUMES
/* If you have root access, you can define DANGEROUS_RENICE and chmod
timidity setuid root to have it automatically raise its priority
when run -- this may make it possible to play MIDI files in the
background while running other CPU-intensive jobs. Of course no
amount of renicing will help if the CPU time simply isn't there.
The root privileges are used and dropped at the beginning of main()
in timidity.c -- please check the code to your satisfaction before
using this option. (And please check sections 11 and 12 in the
GNU General Public License (under GNU Emacs, hit ^H^W) ;) */
/* #define DANGEROUS_RENICE -15 */
/* The number of samples to use for ramping out a dying note. Affects
click removal. */
#define MAX_DIE_TIME 20
/* On some machines (especially PCs without math coprocessors),
looking up sine values in a table will be significantly faster than
computing them on the fly. Uncomment this to use lookups. */
/* #define LOOKUP_SINE */
/* If calling ldexp() is faster than a floating point multiplication
on your machine/compiler/libm, uncomment this. It doesn't make much
difference either way, but hey -- it was on the TODO list, so it
got done. */
/* #define USE_LDEXP */
/**************************************************************************/
/* Anything below this shouldn't need to be changed unless you're porting
to a new machine with other than 32-bit, big-endian words. */
/**************************************************************************/
/* change FRACTION_BITS above, not these */
#define INTEGER_BITS (32 - FRACTION_BITS)
#define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS)
#define FRACTION_MASK (~ INTEGER_MASK)
/* This is enforced by some computations that must fit in an int */
#define MAX_CONTROL_RATIO 255
/* Audio buffer size has to be a power of two to allow DMA buffer
fragments under the VoxWare (Linux & FreeBSD & BSD/OS) audio driver */
#define AUDIO_BUFFER_SIZE (1<<AUDIO_BUFFER_BITS)
#define BB_SIZE (AUDIO_BUFFER_SIZE*512)
#if SIZEOF_LONG == 4
typedef unsigned long uint32;
typedef long int32;
#elif SIZEOF_LONG == 8
typedef unsigned int uint32;
typedef int int32;
#else
#error "We don't know where to find a 32 of our bits!!"
#endif
typedef unsigned short uint16;
typedef short int16;
typedef unsigned char uint8;
typedef char int8;
/* Instrument files are little-endian, MIDI files big-endian, so we
need to do some conversions. */
#ifdef WORDS_BIGENDIAN
#define MIDI_BIG_ENDIAN
#else
#define MIDI_LITTLE_ENDIAN
#endif
#ifdef __FreeBSD__
#include <osreldate.h>
#include <machine/endian.h>
/* The macros have changed
And a better idea would be to attempt the various asm
optimizations ourselves IMO, but hey, this is free */
#if __FreeBSD_version <= 500000
#if defined (__i386__)
#define XCHG_SHORT(x) __byte_swap_word(x)
#define XCHG_LONG(x) __byte_swap_long(x)
#else
#define XCHG_SHORT(x) htons(x)
#define XCHG_LONG(x) htonl(x)
#endif
#else
#define XCHG_SHORT(x) __bswap16(x)
#define XCHG_LONG(x) __bswap32(x)
#endif
#else
#define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
#if defined(__i486__) && defined(__GNUC__)
#define XCHG_LONG(x) \
({ int32 __value; \
asm ("bswap %1; movl %1,%0" : "=g" (__value) : "r" (x)); \
__value; })
#else
#define XCHG_LONG(x) ((((x)&0xFF)<<24) | \
(((x)&0xFF00)<<8) | \
(((x)&0xFF0000)>>8) | \
(((x)>>24)&0xFF))
#endif
#endif
#ifdef MIDI_LITTLE_ENDIAN
#define LE_SHORT(x) x
#define LE_LONG(x) x
#define BE_SHORT(x) XCHG_SHORT(x)
#define BE_LONG(x) XCHG_LONG(x)
#else /* MIDI_BIG_ENDIAN */
#define LE_SHORT(x) XCHG_SHORT(x)
#define LE_LONG(x) XCHG_LONG(x)
#define BE_SHORT(x) x
#define BE_LONG(x) x
#endif
#define MAX_AMPLIFICATION 800
/* You could specify a complete path, e.g. "/etc/timidity.cfg", and
then specify the library directory in the configuration file. */
#ifdef ADAGIO
#define CONFIG_FILE TIMID_DIR "/timidity.cfg"
#else
#ifndef CONFIG_FILE
#define CONFIG_FILE DEFAULT_PATH "/timidity.cfg"
#endif
#endif
/* These affect general volume */
#define GUARD_BITS 3
#define AMP_BITS (15-GUARD_BITS)
#ifdef LOOKUP_HACK
typedef int8 sample_t;
typedef uint8 final_volume_t;
# define FINAL_VOLUME(v) (~_l2u[v])
# define MIXUP_SHIFT 5
# define MAX_AMP_VALUE 4095
#else
typedef int16 sample_t;
typedef int32 final_volume_t;
# define FINAL_VOLUME(v) (v)
# define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1)
#endif
#ifdef tplus
/* #define MIN_AMP_VALUE (MAX_AMP_VALUE >> 9) */
#define MIN_AMP_VALUE (MAX_AMP_VALUE >> 10)
#endif
#ifdef USE_LDEXP
# define FRSCALE(a,b) ldexp((double)(a),(b))
# define FRSCALENEG(a,b) ldexp((double)(a),-(b))
#else
# define FRSCALE(a,b) ((a) * (double)(1<<(b)))
# define FRSCALENEG(a,b) ((a) * (1.0L / (double)(1<<(b))))
#endif
/* Vibrato and tremolo Choices of the Day */
#define SWEEP_TUNING 38
#define VIBRATO_AMPLITUDE_TUNING 1.0L
#define VIBRATO_RATE_TUNING 38
#define TREMOLO_AMPLITUDE_TUNING 1.0L
#define TREMOLO_RATE_TUNING 38
#define SWEEP_SHIFT 16
#define RATE_SHIFT 5
#define VIBRATO_SAMPLE_INCREMENTS 32
#ifdef tplus
#define MODULATION_WHEEL_RATE (1.0/6.0)
#define VIBRATO_DEPTH_TUNING (1.0/4.0)
#endif
#if defined(hpux) || defined(__hpux)
extern char *sys_errlist[];
#define PI 3.14159265358979323846
#endif
#ifdef sun
#ifdef HAVE_SYS_STDTYPES_H
#include <sys/stdtypes.h>
#endif
#include <errno.h>
extern char *sys_errlist[];
extern int opterr;
extern int optind;
extern int optopt;
extern char *optarg;
#define PI 3.14159265358979323846
#define rindex(s,c) strrchr(s,c)
#endif
#ifdef _UNIXWARE
extern char *sys_errlist[];
#include <values.h>
#define PI M_PI
#include <sys/filio.h>
#endif
#ifdef __WIN32__
# include <math.h>
# define PI M_PI
# undef DECOMPRESSOR_LIST
# undef PATCH_EXT_LIST
# define PATCH_EXT_LIST { ".pat", 0 }
#endif
/* The path separator (D.M.) */
#ifdef __WIN32__
# define PATH_SEP '\\'
# define PATH_STRING "\\"
#else
# define PATH_SEP '/'
# define PATH_STRING "/"
#endif
#ifdef __osf__
#include <errno.h>
#define PI 3.14159265358979323846
#endif
#if defined (__FreeBSD__) || defined(__bsdi__)
#include <math.h>
#ifndef PI
#define PI M_PI
#endif
#endif
#ifdef _SCO_DS
#include <math.h>
#ifndef PI
#define PI M_PI
#endif
#endif