timidity/config.h
author Ozkan Sezer <sezeroz@gmail.com>
Sat, 13 Oct 2018 23:02:04 +0300
branchSDL-1.2
changeset 908 6b860486ce24
parent 530 a74d68325094
child 604 c932750a78ce
permissions -rw-r--r--
Mix_InitMP3: unload dll if mpg123_init() fails.
     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 Perl Artistic License, available in COPYING.
     7  */
     8 
     9 /* This is for use with the SDL library */
    10 #define SDL
    11 #include "SDL_config.h"
    12 #include "SDL_endian.h"
    13 
    14 #define TIMIDITY_ERROR_SIZE 1024
    15 
    16 /* When a patch file can't be opened, one of these extensions is
    17    appended to the filename and the open is tried again.
    18  */
    19 #define PATCH_EXT_LIST { ".pat", 0 }
    20 
    21 /* Acoustic Grand Piano seems to be the usual default instrument. */
    22 #define DEFAULT_PROGRAM 0
    23 
    24 /* 9 here is MIDI channel 10, which is the standard percussion channel.
    25    Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. 
    26    On the other hand, some files know that 16 is not a drum channel and
    27    try to play music on it. This is now a runtime option, so this isn't
    28    a critical choice anymore. */
    29 #define DEFAULT_DRUMCHANNELS (1<<9)
    30 
    31 /* A somewhat arbitrary frequency range. The low end of this will
    32    sound terrible as no lowpass filtering is performed on most
    33    instruments before resampling. */
    34 #define MIN_OUTPUT_RATE 	4000
    35 #define MAX_OUTPUT_RATE 	65000
    36 
    37 /* In percent. */
    38 /* #define DEFAULT_AMPLIFICATION 	70 */
    39 /* #define DEFAULT_AMPLIFICATION 	50 */
    40 #define DEFAULT_AMPLIFICATION 	30
    41 
    42 /* Default sampling rate, default polyphony, and maximum polyphony.
    43    All but the last can be overridden from the command line. */
    44 #define DEFAULT_RATE	32000
    45 /* #define DEFAULT_VOICES	32 */
    46 /* #define MAX_VOICES	48 */
    47 #define DEFAULT_VOICES	256
    48 #define MAX_VOICES	256
    49 #define MAXCHAN		16
    50 /* #define MAXCHAN		64 */
    51 #define MAXNOTE		128
    52 
    53 /* 1000 here will give a control ratio of 22:1 with 22 kHz output.
    54    Higher CONTROLS_PER_SECOND values allow more accurate rendering
    55    of envelopes and tremolo. The cost is CPU time. */
    56 #define CONTROLS_PER_SECOND 1000
    57 
    58 /* Strongly recommended. This option increases CPU usage by half, but
    59    without it sound quality is very poor. */
    60 #define LINEAR_INTERPOLATION
    61 
    62 /* This is an experimental kludge that needs to be done right, but if
    63    you've got an 8-bit sound card, or cheap multimedia speakers hooked
    64    to your 16-bit output device, you should definitely give it a try.
    65 
    66    Defining LOOKUP_HACK causes table lookups to be used in mixing
    67    instead of multiplication. We convert the sample data to 8 bits at
    68    load time and volumes to logarithmic 7-bit values before looking up
    69    the product, which degrades sound quality noticeably.
    70 
    71    Defining LOOKUP_HACK should save ~20% of CPU on an Intel machine.
    72    LOOKUP_INTERPOLATION might give another ~5% */
    73 /* #define LOOKUP_HACK
    74    #define LOOKUP_INTERPOLATION */
    75 
    76 /* Make envelopes twice as fast. Saves ~20% CPU time (notes decay
    77    faster) and sounds more like a GUS. There is now a command line
    78    option to toggle this as well. */
    79 /* #define FAST_DECAY */
    80 
    81 /* How many bits to use for the fractional part of sample positions.
    82    This affects tonal accuracy. The entire position counter must fit
    83    in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of
    84    a sample is 1048576 samples (2 megabytes in memory). The GUS gets
    85    by with just 9 bits and a little help from its friends...
    86    "The GUS does not SUCK!!!" -- a happy user :) */
    87 #define FRACTION_BITS 12
    88 
    89 #define MAX_SAMPLE_SIZE (1 << (32-FRACTION_BITS))
    90 
    91 typedef double FLOAT_T;
    92 
    93 /* For some reason the sample volume is always set to maximum in all
    94    patch files. Define this for a crude adjustment that may help
    95    equalize instrument volumes. */
    96 #define ADJUST_SAMPLE_VOLUMES
    97 
    98 /* The number of samples to use for ramping out a dying note. Affects
    99    click removal. */
   100 #define MAX_DIE_TIME 20
   101 
   102 /* On some machines (especially PCs without math coprocessors),
   103    looking up sine values in a table will be significantly faster than
   104    computing them on the fly. Uncomment this to use lookups. */
   105 /* #define LOOKUP_SINE */
   106 
   107 /* Shawn McHorse's resampling optimizations. These may not in fact be
   108    faster on your particular machine and compiler. You'll have to run
   109    a benchmark to find out. */
   110 #define PRECALC_LOOPS
   111 
   112 /* If calling ldexp() is faster than a floating point multiplication
   113    on your machine/compiler/libm, uncomment this. It doesn't make much
   114    difference either way, but hey -- it was on the TODO list, so it
   115    got done. */
   116 /* #define USE_LDEXP */
   117 
   118 /**************************************************************************/
   119 /* Anything below this shouldn't need to be changed unless you're porting
   120    to a new machine with other than 32-bit, big-endian words. */
   121 /**************************************************************************/
   122 
   123 /* change FRACTION_BITS above, not these */
   124 #define INTEGER_BITS (32 - FRACTION_BITS)
   125 #define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS)
   126 #define FRACTION_MASK (~ INTEGER_MASK)
   127 
   128 /* This is enforced by some computations that must fit in an int */
   129 #define MAX_CONTROL_RATIO 255
   130 
   131 typedef unsigned int uint32;
   132 typedef int int32; 
   133 typedef unsigned short uint16;
   134 typedef short int16;
   135 typedef unsigned char uint8;
   136 typedef char int8;
   137 
   138 /* Instrument files are little-endian, MIDI files big-endian, so we
   139    need to do some conversions. */
   140 
   141 #define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
   142 # define XCHG_LONG(x) ((((x)&0xFF)<<24) | \
   143 		      (((x)&0xFF00)<<8) | \
   144 		      (((x)&0xFF0000)>>8) | \
   145 		      (((x)>>24)&0xFF))
   146 
   147 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
   148 #define LE_SHORT(x) x
   149 #define LE_LONG(x) x
   150 #define BE_SHORT(x) XCHG_SHORT(x)
   151 #define BE_LONG(x) XCHG_LONG(x)
   152 #else
   153 #define BE_SHORT(x) x
   154 #define BE_LONG(x) x
   155 #define LE_SHORT(x) XCHG_SHORT(x)
   156 #define LE_LONG(x) XCHG_LONG(x)
   157 #endif
   158 
   159 #define MAX_AMPLIFICATION 800
   160 
   161 /* You could specify a complete path, e.g. "/etc/timidity.cfg", and
   162    then specify the library directory in the configuration file. */
   163 #define CONFIG_FILE	"timidity.cfg"
   164 #define CONFIG_FILE_ETC "/etc/timidity.cfg"
   165 
   166 #if defined(__WIN32__) || defined(__OS2__)
   167 #define DEFAULT_PATH	"C:\\TIMIDITY"
   168 #else
   169 #define DEFAULT_PATH	"/etc/timidity"
   170 #define DEFAULT_PATH1	"/usr/share/timidity"
   171 #define DEFAULT_PATH2	"/usr/local/share/timidity"
   172 #define DEFAULT_PATH3	"/usr/local/lib/timidity"
   173 #endif
   174 
   175 /* These affect general volume */
   176 #define GUARD_BITS 3
   177 #define AMP_BITS (15-GUARD_BITS)
   178 
   179 #ifdef LOOKUP_HACK
   180    typedef int8 sample_t;
   181    typedef uint8 final_volume_t;
   182 #  define FINAL_VOLUME(v) (~_l2u[v])
   183 #  define MIXUP_SHIFT 5
   184 #  define MAX_AMP_VALUE 4095
   185 #else
   186    typedef int16 sample_t;
   187    typedef int32 final_volume_t;
   188 #  define FINAL_VOLUME(v) (v)
   189 #  define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1)
   190 #endif
   191 
   192 typedef int16 resample_t;
   193 
   194 #ifdef USE_LDEXP
   195 #  define FSCALE(a,b) ldexp((a),(b))
   196 #  define FSCALENEG(a,b) ldexp((a),-(b))
   197 #else
   198 #  define FSCALE(a,b) (float)((a) * (double)(1<<(b)))
   199 #  define FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b))))
   200 #endif
   201 
   202 /* Vibrato and tremolo Choices of the Day */
   203 #define SWEEP_TUNING 38
   204 #define VIBRATO_AMPLITUDE_TUNING 1.0L
   205 #define VIBRATO_RATE_TUNING 38
   206 #define TREMOLO_AMPLITUDE_TUNING 1.0L
   207 #define TREMOLO_RATE_TUNING 38
   208 
   209 #define SWEEP_SHIFT 16
   210 #define RATE_SHIFT 5
   211 
   212 #define VIBRATO_SAMPLE_INCREMENTS 32
   213 
   214 #ifndef PI
   215   #define PI 3.14159265358979323846
   216 #endif
   217 
   218 /* The path separator (D.M.) */
   219 #if defined(__WIN32__) || defined(__OS2__)
   220 #  define PATH_SEP '\\'
   221 #  define PATH_STRING "\\"
   222 #else
   223 #  define PATH_SEP '/'
   224 #  define PATH_STRING "/"
   225 #endif