DOOM-3-BFG

DOOM 3 BFG Edition
Log | Files | Refs

config.h (6902B)


      1 /*
      2 TiMidity -- Experimental MIDI to WAVE converter
      3 Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
      4 
      5 This program is free software; you can redistribute it and/or modify
      6 it under the terms of the GNU General Public License as published by
      7 the Free Software Foundation; either version 2 of the License, or
      8 (at your option) any later version.
      9 
     10 This program is distributed in the hope that it will be useful,
     11 but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 GNU General Public License for more details.
     14 
     15 You should have received a copy of the GNU General Public License
     16 along with this program; if not, write to the Free Software
     17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     18 */
     19 
     20 /* This is for use with the SDL library */
     21 #define SDL
     22 #if (defined(WIN32) || defined(_WIN32)) && !defined(__WIN32__)
     23 #define __WIN32__
     24 #endif
     25 
     26 #define LITTLE_ENDIAN
     27 
     28 #include <stdint.h>
     29 
     30 /* When a patch file can't be opened, one of these extensions is
     31 appended to the filename and the open is tried again.
     32 */
     33 #define PATCH_EXT_LIST { ".pat", 0 }
     34 
     35 /* Acoustic Grand Piano seems to be the usual default instrument. */
     36 #define DEFAULT_PROGRAM 0
     37 
     38 /* 9 here is MIDI channel 10, which is the standard percussion channel.
     39 Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. 
     40 On the other hand, some files know that 16 is not a drum channel and
     41 try to play music on it. This is now a runtime option, so this isn't
     42 a critical choice anymore. */
     43 //#define DEFAULT_DRUMCHANNELS ((1<<9) | (1<<15))
     44 #define DEFAULT_DRUMCHANNELS ((1<<9))
     45 
     46 /* A somewhat arbitrary frequency range. The low end of this will
     47 sound terrible as no lowpass filtering is performed on most
     48 instruments before resampling. */
     49 #define MIN_OUTPUT_RATE 	4000
     50 #define MAX_OUTPUT_RATE 	65000
     51 
     52 /* In percent. */
     53 #define DEFAULT_AMPLIFICATION 	70
     54 
     55 /* Default sampling rate, default polyphony, and maximum polyphony.
     56 All but the last can be overridden from the command line. */
     57 #define DEFAULT_RATE	32000
     58 #define DEFAULT_VOICES	32
     59 #define MAX_VOICES	48
     60 
     61 /* 1000 here will give a control ratio of 22:1 with 22 kHz output.
     62 Higher CONTROLS_PER_SECOND values allow more accurate rendering
     63 of envelopes and tremolo. The cost is CPU time. */
     64 #define CONTROLS_PER_SECOND 1000
     65 
     66 /* Strongly recommended. This option increases CPU usage by half, but
     67 without it sound quality is very poor. */
     68 #define LINEAR_INTERPOLATION
     69 
     70 /* This is an experimental kludge that needs to be done right, but if
     71 you've got an 8-bit sound card, or cheap multimedia speakers hooked
     72 to your 16-bit output device, you should definitely give it a try.
     73 
     74 Defining LOOKUP_HACK causes table lookups to be used in mixing
     75 instead of multiplication. We convert the sample data to 8 bits at
     76 load time and volumes to logarithmic 7-bit values before looking up
     77 the product, which degrades sound quality noticeably.
     78 
     79 Defining LOOKUP_HACK should save ~20% of CPU on an Intel machine.
     80 LOOKUP_INTERPOLATION might give another ~5% */
     81 /* #define LOOKUP_HACK
     82 #define LOOKUP_INTERPOLATION */
     83 
     84 /* Make envelopes twice as fast. Saves ~20% CPU time (notes decay
     85 faster) and sounds more like a GUS. There is now a command line
     86 option to toggle this as well. */
     87 #define FAST_DECAY
     88 
     89 /* How many bits to use for the fractional part of sample positions.
     90 This affects tonal accuracy. The entire position counter must fit
     91 in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of
     92 a sample is 1048576 samples (2 megabytes in memory). The GUS gets
     93 by with just 9 bits and a little help from its friends...
     94 "The GUS does not SUCK!!!" -- a happy user :) */
     95 #define FRACTION_BITS 12
     96 
     97 /* For some reason the sample volume is always set to maximum in all
     98 patch files. Define this for a crude adjustment that may help
     99 equalize instrument volumes. */
    100 #define ADJUST_SAMPLE_VOLUMES
    101 
    102 /* The number of samples to use for ramping out a dying note. Affects
    103 click removal. */
    104 #define MAX_DIE_TIME 20
    105 
    106 /* On some machines (especially PCs without math coprocessors),
    107 looking up sine values in a table will be significantly faster than
    108 computing them on the fly. Uncomment this to use lookups. */
    109 /* #define LOOKUP_SINE */
    110 
    111 /* Shawn McHorse's resampling optimizations. These may not in fact be
    112 faster on your particular machine and compiler. You'll have to run
    113 a benchmark to find out. */
    114 #define PRECALC_LOOPS
    115 
    116 /* If calling ldexp() is faster than a floating point multiplication
    117 on your machine/compiler/libm, uncomment this. It doesn't make much
    118 difference either way, but hey -- it was on the TODO list, so it
    119 got done. */
    120 /* #define USE_LDEXP */
    121 
    122 /**************************************************************************/
    123 /* Anything below this shouldn't need to be changed unless you're porting
    124 to a new machine with other than 32-bit, big-endian words. */
    125 /**************************************************************************/
    126 
    127 /* change FRACTION_BITS above, not these */
    128 #define INTEGER_BITS (32 - FRACTION_BITS)
    129 #define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS)
    130 #define FRACTION_MASK (~ INTEGER_MASK)
    131 
    132 /* This is enforced by some computations that must fit in an int */
    133 #define MAX_CONTROL_RATIO 255
    134 
    135 /* Instrument files are little-endian, MIDI files big-endian, so we
    136 need to do some conversions. */
    137 
    138 #define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
    139 # define XCHG_LONG(x) ((((x)&0xFF)<<24) | \
    140 	(((x)&0xFF00)<<8) | \
    141 	(((x)&0xFF0000)>>8) | \
    142 	(((x)>>24)&0xFF))
    143 
    144 #ifdef LITTLE_ENDIAN
    145 #define LE_SHORT(x) x
    146 #define LE_LONG(x) x
    147 #define BE_SHORT(x) XCHG_SHORT(x)
    148 #define BE_LONG(x) XCHG_LONG(x)
    149 #else
    150 #define BE_SHORT(x) x
    151 #define BE_LONG(x) x
    152 #define LE_SHORT(x) XCHG_SHORT(x)
    153 #define LE_LONG(x) XCHG_LONG(x)
    154 #endif
    155 
    156 #define MAX_AMPLIFICATION 800
    157 
    158 /* These affect general volume */
    159 #define GUARD_BITS 3
    160 #define AMP_BITS (15-GUARD_BITS)
    161 
    162 #ifdef LOOKUP_HACK
    163 typedef int8_t sample_t;
    164 typedef uint8_t final_volume_t;
    165 #  define FINAL_VOLUME(v) (~_l2u[v])
    166 #  define MIXUP_SHIFT 5
    167 #  define MAX_AMP_VALUE 4095
    168 #else
    169 typedef int16_t sample_t;
    170 typedef  int32_t  final_volume_t;
    171 #  define FINAL_VOLUME(v) (v)
    172 #  define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1)
    173 #endif
    174 
    175 #ifdef USE_LDEXP
    176 #  define FSCALE(a,b) ldexp((a),(b))
    177 #  define FSCALENEG(a,b) ldexp((a),-(b))
    178 #else
    179 #  define FSCALE(a,b) (float)((a) * (double)(1<<(b)))
    180 #  define FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b))))
    181 #endif
    182 
    183 /* Vibrato and tremolo Choices of the Day */
    184 #define SWEEP_TUNING 38
    185 #define VIBRATO_AMPLITUDE_TUNING 1.0L
    186 #define VIBRATO_RATE_TUNING 38
    187 #define TREMOLO_AMPLITUDE_TUNING 1.0L
    188 #define TREMOLO_RATE_TUNING 38
    189 
    190 #define SWEEP_SHIFT 16
    191 #define RATE_SHIFT 5
    192 
    193 #define VIBRATO_SAMPLE_INCREMENTS 32
    194 
    195 #ifndef PI
    196 const float PI =  3.14159265358979323846f;
    197 #endif
    198 
    199 /* The path separator (D.M.) */
    200 //#ifdef __WIN32__
    201 #  define PATH_SEP '\\'
    202 #  define PATH_STRING "\\"
    203 //#else
    204 //#  define PATH_SEP '/'
    205 //#  define PATH_STRING "/"
    206 //#endif