1 /*
2     TiMidity++ -- MIDI to WAVE converter and player
3     Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
4     Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
5 
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10 
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20 
21 /*
22  * Historical issues: This file once was a huge header file, but now is
23  * devided into some smaller ones.  Please do not add things to this
24  * header, but consider put them on other files.
25  */
26 
27 
28 #ifndef TIMIDITY_H_INCLUDED
29 #define TIMIDITY_H_INCLUDED 1
30 
31 #include "controls.h"
32 #include "mblock.h"
33 #include "../../../source/zmusic/critsec.h"
34 #include <mutex>
35 #include <stdint.h>
36 
37 #ifdef _MSC_VER
38 #pragma warning(disable:4244)	// double->float truncation occurs so often in here that it's pointless to fix it all.
39 #endif
40 
41 
42 
43 /*
44    Table of contents:
45    (1) Flags and definitions to customize timidity
46    (3) inportant definitions not to customize
47    (2) #includes -- include other headers
48  */
49 
50 /*****************************************************************************\
51  section 1: some customize issues
52 \*****************************************************************************/
53 
54 
55 /* How many bits to use for the fractional part of sample positions.
56    This affects tonal accuracy. The entire position counter must fit
57    in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of
58    a sample is 1048576 samples (2 megabytes in memory). The GUS gets
59    by with just 9 bits and a little help from its friends...
60    "The GUS does not SUCK!!!" -- a happy user :) */
61 #define FRACTION_BITS 12
62    /* change FRACTION_BITS above, not this */
63 #define FRACTION_MASK (~(0xFFFFFFFF << FRACTION_BITS))
64 
65 
66 /* The number of samples to use for ramping out a dying note. Affects
67    click removal. */
68 #define MAX_DIE_TIME 20
69 
70 
71 /* Define the pre-resampling cache size.
72  * This value is default. You can change the cache saze with
73  * command line option.
74  */
75 #define DEFAULT_CACHE_DATA_SIZE (2*1024*1024)
76 
77 
78 /*****************************************************************************\
79  section 2: some important definitions
80 \*****************************************************************************/
81 /*
82   Anything below this shouldn't need to be changed unless you're porting
83    to a new machine with other than 32-bit, big-endian words.
84  */
85 
86 
87 /* Audio buffer size has to be a power of two to allow DMA buffer
88    fragments under the VoxWare (Linux & FreeBSD) audio driver */
89 #define AUDIO_BUFFER_SIZE (1<<12)
90 
91 /* These affect general volume */
92 #define GUARD_BITS 3
93 #define AMP_BITS (15-GUARD_BITS)
94 
95 #define MAX_AMPLIFICATION 800
96 #define MAX_CHANNELS 32
97 
98 /* Vibrato and tremolo Choices of the Day */
99 #define SWEEP_TUNING 38
100 #define VIBRATO_AMPLITUDE_TUNING 1.0L
101 #define VIBRATO_RATE_TUNING 38
102 #define TREMOLO_AMPLITUDE_TUNING 1.0L
103 #define TREMOLO_RATE_TUNING 38
104 
105 #define SWEEP_SHIFT 16
106 #define RATE_SHIFT 5
107 
108 #define VIBRATO_SAMPLE_INCREMENTS 32
109 
110 #define MODULATION_WHEEL_RATE (1.0/6.0)
111 /* #define MODULATION_WHEEL_RATE (midi_time_ratio/8.0) */
112 /* #define MODULATION_WHEEL_RATE (current_play_tempo/500000.0/32.0) */
113 
114 #define VIBRATO_DEPTH_TUNING (1.0/4.0)
115 
116 /* malloc's limit */
117 #define MAX_SAFE_MALLOC_SIZE (1<<23) /* 8M */
118 
119 #define DEFAULT_SOUNDFONT_ORDER 0
120 
121 
122 /*****************************************************************************\
123  section 3: include other headers
124 \*****************************************************************************/
125 
126 namespace TimidityPlus
127 {
128 
129 extern FCriticalSection ConfigMutex;
130 extern int timidity_modulation_wheel;
131 extern int timidity_portamento;
132 extern int timidity_reverb;
133 extern int timidity_chorus;
134 extern int timidity_surround_chorus;
135 extern int timidity_channel_pressure;
136 extern int timidity_lpf_de;
137 extern int timidity_temper_control;
138 extern int timidity_modulation_envelope;
139 extern int timidity_overlap_voice_allow;
140 extern int timidity_drum_effect;
141 extern int timidity_pan_delay;
142 extern float timidity_drum_power;
143 extern int timidity_key_adjust;
144 extern float timidity_tempo_adjust;
145 extern float min_sustain_time;
146 extern int timidity_lpf_def;
147 
148 extern int32_t playback_rate;
149 extern int32_t control_ratio;	// derived from playback_rate
150 
151 enum play_system_modes
152 {
153 	DEFAULT_SYSTEM_MODE,
154 	GM_SYSTEM_MODE,
155 	GM2_SYSTEM_MODE,
156 	GS_SYSTEM_MODE,
157 	XG_SYSTEM_MODE
158 };
159 
160 
161 const int DEFAULT_VOICES = 256;
162 
163 // These were configurable in Timidity++ but it doesn't look like this is really needed.
164 // In case it becomes necessary, they can be turned into CVARs.
165 const int default_tonebank = 0;
166 const int special_tonebank = -1;
167 const int effect_lr_mode = -1;
168 const int effect_lr_delay_msec = 25;
169 const int adjust_panning_immediately = 1;
170 const int antialiasing_allowed = 0;
171 const int fast_decay = 0;
172 const int cutoff_allowed = 0;
173 const int opt_force_keysig = 8;
174 const int max_voices = DEFAULT_VOICES;
175 const int temper_type_mute = 0;
176 const int opt_preserve_silence = 0;
177 const int opt_init_keysig = 8;
178 
179 }
180 #endif /* TIMIDITY_H_INCLUDED */
181