2
$Id: config.h,v 1.51 2001/06/06 18:56:02 mueller Exp $
4
TiMidity -- Experimental MIDI to WAVE converter
5
Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
#include "../config.h"
30
#include "../../config.h"
31
/* if above referenced file does not exist, use something like:
44
#define TIMID_DIR DEFAULT_PATH
46
#define TIMID_DIR "/usr/local/lib/timidity"
50
/* Enable extensions taken from TiMidity++ */
53
/* Enable Nicolas Witczak's effects processing */
54
#define CHANNEL_EFFECT
56
/* Filename extension, followed by command to run decompressor so that
57
output is written to stdout. Terminate the list with a 0.
59
Any file with a name ending in one of these strings will be run
60
through the corresponding decompressor. If you don't like this
61
behavior, you can undefine DECOMPRESSOR_LIST to disable automatic
62
decompression entirely.
64
This is currently ignored for Win32. */
65
#define DECOMPRESSOR_LIST { \
66
".gz", "gunzip -c %s", \
67
".bz2", "bzip2 -cd %s", \
69
".zip", "unzip -p %s", \
70
".lha", "lha -pq %s", \
71
".lzh", "lha -pq %s", \
72
".shn", "shorten -x %s -", \
73
".wav", "wav2pat %s", \
76
/* When a patch file can't be opened, one of these extensions is
77
appended to the filename and the open is tried again.
79
This is ignored for Win32, which uses only ".pat" (see the bottom
80
of this file if you need to change this.) */
81
#define PATCH_EXT_LIST { \
87
/* Acoustic Grand Piano seems to be the usual default instrument. */
88
#define DEFAULT_PROGRAM 0
90
/* 9 here is MIDI channel 10, which is the standard percussion channel.
91
Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too.
92
On the other hand, some files know that 16 is not a drum channel and
93
try to play music on it. This is now a runtime option, so this isn't
94
a critical choice anymore. */
95
#define DEFAULT_DRUMCHANNELS (1<<9)
96
/*#define DEFAULT_DRUMCHANNELS ((1<<9) | (1<<15))*/
98
/* type of floating point number */
99
typedef double FLOAT_T;
100
/* typedef float FLOAT_T; */
102
/* A somewhat arbitrary frequency range. The low end of this will
103
sound terrible as no lowpass filtering is performed on most
104
instruments before resampling. */
105
#define MIN_OUTPUT_RATE 4000
106
#define MAX_OUTPUT_RATE 65000
109
#ifndef DEFAULT_AMPLIFICATION
110
#define DEFAULT_AMPLIFICATION 70
113
/* Default sampling rate, default polyphony, and maximum polyphony.
114
All but the last can be overridden from the command line. */
116
/*#define DEFAULT_RATE 32000*/
117
#define DEFAULT_RATE 44100
120
#ifndef DEFAULT_VOICES
122
#define DEFAULT_VOICES DEFAULT_DSPVOICES
124
#define DEFAULT_VOICES 64
130
/* Should check this. MAX_DSPVOICES should be the
131
number of Timidity "channels", but the maximum number
132
of polyphonic voices playing simultaneously should be
133
larger. Now the two maxima are treated the same.
135
#define MAX_VOICES MAX_DSPVOICES
137
#define MAX_VOICES 128
141
/* The size of the internal buffer is 2^AUDIO_BUFFER_BITS samples.
142
This determines maximum number of samples ever computed in a row.
144
For Linux, FreeBSD and BSD/OS users:
146
This also specifies the size of the buffer fragment. A smaller
147
fragment gives a faster response in interactive mode -- 10 or 11 is
148
probably a good number. Unfortunately some sound cards emit a click
149
when switching DMA buffers. If this happens to you, try increasing
150
this number to reduce the frequency of the clicks.
154
You should probably use a larger number for improved performance.
158
#define AUDIO_BUFFER_BITS 12
160
/** #define AUDIO_BUFFER_BITS 11 **/
161
#define AUDIO_BUFFER_BITS 10
164
/* 1000 here will give a control ratio of 22:1 with 22 kHz output.
165
Higher CONTROLS_PER_SECOND values allow more accurate rendering
166
of envelopes and tremolo. The cost is CPU time. */
167
/*#define CONTROLS_PER_SECOND 1000*/
168
#define CONTROLS_PER_SECOND 2000
170
/* Make envelopes twice as fast. Saves ~20% CPU time (notes decay
171
faster) and sounds more like a GUS. There is now a command line
172
option to toggle this as well. */
173
/*#define FAST_DECAY*/
175
/* How many bits to use for the fractional part of sample positions.
176
This affects tonal accuracy. The entire position counter must fit
177
in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of
178
a sample is 1048576 samples (2 megabytes in memory). The GUS gets
179
by with just 9 bits and a little help from its friends...
180
"The GUS does not SUCK!!!" -- a happy user :) */
181
/* #define FRACTION_BITS 12 */
182
#define FRACTION_BITS 13
184
/* For some reason the sample volume is always set to maximum in all
185
patch files. Define this for a crude adjustment that may help
186
equalize instrument volumes. */
187
#define ADJUST_SAMPLE_VOLUMES
189
/* If you have root access, you can define DANGEROUS_RENICE and chmod
190
timidity setuid root to have it automatically raise its priority
191
when run -- this may make it possible to play MIDI files in the
192
background while running other CPU-intensive jobs. Of course no
193
amount of renicing will help if the CPU time simply isn't there.
195
The root privileges are used and dropped at the beginning of main()
196
in timidity.c -- please check the code to your satisfaction before
197
using this option. (And please check sections 11 and 12 in the
198
GNU General Public License (under GNU Emacs, hit ^H^W) ;) */
199
/* #define DANGEROUS_RENICE -15 */
201
/* The number of samples to use for ramping out a dying note. Affects
203
#define MAX_DIE_TIME 20
205
/* On some machines (especially PCs without math coprocessors),
206
looking up sine values in a table will be significantly faster than
207
computing them on the fly. Uncomment this to use lookups. */
208
/* #define LOOKUP_SINE */
210
/* If calling ldexp() is faster than a floating point multiplication
211
on your machine/compiler/libm, uncomment this. It doesn't make much
212
difference either way, but hey -- it was on the TODO list, so it
214
/* #define USE_LDEXP */
216
/**************************************************************************/
217
/* Anything below this shouldn't need to be changed unless you're porting
218
to a new machine with other than 32-bit, big-endian words. */
219
/**************************************************************************/
221
/* change FRACTION_BITS above, not these */
222
#define INTEGER_BITS (32 - FRACTION_BITS)
223
#define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS)
224
#define FRACTION_MASK (~ INTEGER_MASK)
226
/* This is enforced by some computations that must fit in an int */
227
#define MAX_CONTROL_RATIO 255
229
/* Audio buffer size has to be a power of two to allow DMA buffer
230
fragments under the VoxWare (Linux & FreeBSD & BSD/OS) audio driver */
231
#define AUDIO_BUFFER_SIZE (1<<AUDIO_BUFFER_BITS)
232
#define BB_SIZE (AUDIO_BUFFER_SIZE*512)
235
typedef unsigned long uint32;
237
#elif SIZEOF_LONG == 8
238
typedef unsigned int uint32;
241
#error "We don't know where to find a 32 of our bits!!"
243
typedef unsigned short uint16;
245
typedef unsigned char uint8;
248
/* Instrument files are little-endian, MIDI files big-endian, so we
249
need to do some conversions. */
251
#ifdef WORDS_BIGENDIAN
252
#define MIDI_BIG_ENDIAN
254
#define MIDI_LITTLE_ENDIAN
258
#include <osreldate.h>
259
#include <machine/endian.h>
260
/* The macros have changed recently */
261
/* And a better idea would be to attempt the various asm
262
optimizations ourselves IMO, but hey, this is free */
263
#if __FreeBSD_version <= 500000
264
#define XCHG_SHORT(x) __byte_swap_word(x)
265
#define XCHG_LONG(x) __byte_swap_long(x)
267
#define XCHG_SHORT(x) __uint8_swap_uint16(x)
268
#define XCHG_LONG(x) __uint8_swap_uint32(x)
271
#define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
273
#define XCHG_LONG(x) \
275
asm ("bswap %1; movl %1,%0" : "=g" (__value) : "r" (x)); \
278
#define XCHG_LONG(x) ((((x)&0xFF)<<24) | \
279
(((x)&0xFF00)<<8) | \
280
(((x)&0xFF0000)>>8) | \
285
#ifdef MIDI_LITTLE_ENDIAN
286
#define LE_SHORT(x) x
288
#define BE_SHORT(x) XCHG_SHORT(x)
289
#define BE_LONG(x) XCHG_LONG(x)
290
#else /* MIDI_BIG_ENDIAN */
291
#define LE_SHORT(x) XCHG_SHORT(x)
292
#define LE_LONG(x) XCHG_LONG(x)
293
#define BE_SHORT(x) x
297
#define MAX_AMPLIFICATION 800
299
/* You could specify a complete path, e.g. "/etc/timidity.cfg", and
300
then specify the library directory in the configuration file. */
302
#define CONFIG_FILE TIMID_DIR "/timidity.cfg"
305
#define CONFIG_FILE DEFAULT_PATH "/timidity.cfg"
309
/* These affect general volume */
311
#define AMP_BITS (15-GUARD_BITS)
314
typedef int8 sample_t;
315
typedef uint8 final_volume_t;
316
# define FINAL_VOLUME(v) (~_l2u[v])
317
# define MIXUP_SHIFT 5
318
# define MAX_AMP_VALUE 4095
320
typedef int16 sample_t;
321
typedef int32 final_volume_t;
322
# define FINAL_VOLUME(v) (v)
323
# define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1)
327
/* #define MIN_AMP_VALUE (MAX_AMP_VALUE >> 9) */
328
#define MIN_AMP_VALUE (MAX_AMP_VALUE >> 10)
332
# define FRSCALE(a,b) ldexp((double)(a),(b))
333
# define FRSCALENEG(a,b) ldexp((double)(a),-(b))
335
# define FRSCALE(a,b) ((a) * (double)(1<<(b)))
336
# define FRSCALENEG(a,b) ((a) * (1.0L / (double)(1<<(b))))
339
/* Vibrato and tremolo Choices of the Day */
340
#define SWEEP_TUNING 38
341
#define VIBRATO_AMPLITUDE_TUNING 1.0L
342
#define VIBRATO_RATE_TUNING 38
343
#define TREMOLO_AMPLITUDE_TUNING 1.0L
344
#define TREMOLO_RATE_TUNING 38
346
#define SWEEP_SHIFT 16
349
#define VIBRATO_SAMPLE_INCREMENTS 32
353
#define MODULATION_WHEEL_RATE (1.0/6.0)
354
#define VIBRATO_DEPTH_TUNING (1.0/4.0)
357
#if defined(hpux) || defined(__hpux)
358
extern char *sys_errlist[];
359
#define PI 3.14159265358979323846
363
#ifdef HAVE_SYS_STDTYPES_H
364
#include <sys/stdtypes.h>
367
extern char *sys_errlist[];
372
#define PI 3.14159265358979323846
373
#define rindex(s,c) strrchr(s,c)
377
extern char *sys_errlist[];
380
#include <sys/filio.h>
386
# undef DECOMPRESSOR_LIST
387
# undef PATCH_EXT_LIST
388
# define PATCH_EXT_LIST { ".pat", 0 }
391
/* The path separator (D.M.) */
393
# define PATH_SEP '\\'
394
# define PATH_STRING "\\"
396
# define PATH_SEP '/'
397
# define PATH_STRING "/"
402
#define PI 3.14159265358979323846
405
#if defined (__FreeBSD__) || defined(__bsdi__)