Skip to content

Latest commit

 

History

History
183 lines (151 loc) · 4.39 KB

instrum.h

File metadata and controls

183 lines (151 loc) · 4.39 KB
 
Oct 21, 1999
Oct 21, 1999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
TiMidity -- Experimental MIDI to WAVE converter
Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
instrum.h
*/
Aug 21, 2004
Aug 21, 2004
24
Oct 21, 1999
Oct 21, 1999
25
26
27
28
typedef struct {
int32
loop_start, loop_end, data_length,
sample_rate, low_freq, high_freq, root_freq;
Aug 21, 2004
Aug 21, 2004
29
30
uint8
root_tune, fine_tune;
Oct 21, 1999
Oct 21, 1999
31
int32
Aug 21, 2004
Aug 21, 2004
32
33
34
35
36
envelope_rate[7], envelope_offset[7],
modulation_rate[7], modulation_offset[7];
FLOAT_T
volume, resonance,
modEnvToFilterFc, modEnvToPitch, modLfoToFilterFc;
Oct 21, 1999
Oct 21, 1999
37
38
39
sample_t *data;
int32
tremolo_sweep_increment, tremolo_phase_increment,
Aug 21, 2004
Aug 21, 2004
40
41
42
lfo_sweep_increment, lfo_phase_increment,
vibrato_sweep_increment, vibrato_control_ratio,
cutoff_freq;
Oct 21, 1999
Oct 21, 1999
43
uint8
Aug 21, 2004
Aug 21, 2004
44
reverberation, chorusdepth,
Oct 21, 1999
Oct 21, 1999
45
46
tremolo_depth, vibrato_depth,
modes;
Aug 21, 2004
Aug 21, 2004
47
48
uint8
attenuation, freq_center;
Oct 21, 1999
Oct 21, 1999
49
int8
Aug 21, 2004
Aug 21, 2004
50
51
52
53
54
55
panning, note_to_use, exclusiveClass;
int16
scale_tuning, keyToModEnvHold, keyToModEnvDecay,
keyToVolEnvHold, keyToVolEnvDecay;
int32
freq_scale, vibrato_delay;
Oct 21, 1999
Oct 21, 1999
56
57
58
59
60
61
62
63
64
65
} Sample;
/* Bits in modes: */
#define MODES_16BIT (1<<0)
#define MODES_UNSIGNED (1<<1)
#define MODES_LOOPING (1<<2)
#define MODES_PINGPONG (1<<3)
#define MODES_REVERSE (1<<4)
#define MODES_SUSTAIN (1<<5)
#define MODES_ENVELOPE (1<<6)
Aug 21, 2004
Aug 21, 2004
66
#define MODES_FAST_RELEASE (1<<7)
Oct 21, 1999
Oct 21, 1999
67
Aug 21, 2004
Aug 21, 2004
68
#if 0
Oct 21, 1999
Oct 21, 1999
69
70
71
72
typedef struct {
int samples;
Sample *sample;
} Instrument;
Aug 21, 2004
Aug 21, 2004
73
74
75
76
#endif
#define INST_GUS 0
#define INST_SF2 1
Oct 21, 1999
Oct 21, 1999
77
78
typedef struct {
Aug 21, 2004
Aug 21, 2004
79
80
81
82
83
84
85
86
87
88
89
90
91
92
int type;
int samples;
Sample *sample;
int left_samples;
Sample *left_sample;
int right_samples;
Sample *right_sample;
unsigned char *contents;
} Instrument;
typedef struct _InstrumentLayer {
uint8 lo, hi;
int size;
Oct 21, 1999
Oct 21, 1999
93
Instrument *instrument;
Aug 21, 2004
Aug 21, 2004
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
struct _InstrumentLayer *next;
} InstrumentLayer;
struct cfg_type {
int font_code;
int num;
const char *name;
};
#define FONT_NORMAL 0
#define FONT_FFF 1
#define FONT_SBK 2
#define FONT_TONESET 3
#define FONT_DRUMSET 4
#define FONT_PRESET 5
typedef struct {
char *name;
InstrumentLayer *layer;
int font_type, sf_ix, last_used, tuning;
Oct 21, 1999
Oct 21, 1999
115
116
117
int note, amp, pan, strip_loop, strip_envelope, strip_tail;
} ToneBankElement;
Aug 21, 2004
Aug 21, 2004
118
119
120
121
122
123
124
#if 0
typedef struct {
char *name;
Instrument *instrument;
int note, amp, pan, strip_loop, strip_envelope, strip_tail;
} ToneBankElement;
#endif
Oct 21, 1999
Oct 21, 1999
125
126
/* A hack to delay instrument loading until after reading the
entire MIDI file. */
Aug 21, 2004
Aug 21, 2004
127
#define MAGIC_LOAD_INSTRUMENT ((InstrumentLayer *)(-1))
Oct 21, 1999
Oct 21, 1999
128
Aug 21, 2004
Aug 21, 2004
129
130
131
132
133
134
135
136
#define MAXPROG 128
#define MAXBANK 130
#define SFXBANK (MAXBANK-1)
#define SFXDRUM1 (MAXBANK-2)
#define SFXDRUM2 (MAXBANK-1)
#define XGDRUM 1
#if 0
Oct 21, 1999
Oct 21, 1999
137
138
139
typedef struct {
ToneBankElement tone[128];
} ToneBank;
Aug 21, 2004
Aug 21, 2004
140
141
142
143
144
145
146
147
148
#endif
typedef struct {
char *name;
ToneBankElement tone[MAXPROG];
} ToneBank;
extern char *sf_file;
Oct 21, 1999
Oct 21, 1999
149
150
151
extern ToneBank *tonebank[], *drumset[];
Aug 21, 2004
Aug 21, 2004
152
#if 0
Oct 21, 1999
Oct 21, 1999
153
extern Instrument *default_instrument;
Aug 21, 2004
Aug 21, 2004
154
155
#endif
extern InstrumentLayer *default_instrument;
Oct 21, 1999
Oct 21, 1999
156
157
158
159
160
161
162
163
164
extern int default_program;
extern int antialiasing_allowed;
extern int fast_decay;
extern int free_instruments_afterwards;
#define SPECIAL_PROGRAM -1
extern int load_missing_instruments(void);
extern void free_instruments(void);
Aug 21, 2004
Aug 21, 2004
165
extern void end_soundfont(void);
Oct 21, 1999
Oct 21, 1999
166
167
extern int set_default_instrument(char *name);
Aug 21, 2004
Aug 21, 2004
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
extern int32 convert_tremolo_sweep(uint8 sweep);
extern int32 convert_vibrato_sweep(uint8 sweep, int32 vib_control_ratio);
extern int32 convert_tremolo_rate(uint8 rate);
extern int32 convert_vibrato_rate(uint8 rate);
extern int init_soundfont(char *fname, int oldbank, int newbank, int level);
extern InstrumentLayer *load_sbk_patch(const char *name, int gm_num, int bank, int percussion,
int panning, int amp, int note_to_use, int sf_ix);
extern int current_tune_number;
extern int max_patch_memory;
extern int current_patch_memory;
#define XMAPMAX 800
extern int xmap[XMAPMAX][5];
extern void pcmap(int *b, int *v, int *p, int *drums);