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