-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.h
253 lines (195 loc) · 6.02 KB
/
globals.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*
ZynAddSubFX - a software synthesizer
globals.h - it contains program settings and the program capabilities
like number of parts, of effects
Copyright (C) 2002-2005 Nasca Octavian Paul
Author: Nasca Octavian Paul
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License
as published by the Free Software Foundation.
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 (version 2 or later) for more details.
You should have received a copy of the GNU General Public License (version 2)
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GLOBALS_H
#define GLOBALS_H
//What float type I use for internal sampledata
#define REALTYPE float
struct FFTFREQS {
REALTYPE *s, *c; //sine and cosine components
};
extern void newFFTFREQS(FFTFREQS *f, int size);
extern void deleteFFTFREQS(FFTFREQS *f);
/**Sampling rate*/
extern int SAMPLE_RATE;
/**
* The size of a sound buffer (or the granularity)
* All internal transfer of sound data use buffer of this size
* All parameters are constant during this period of time, exception
* some parameters(like amplitudes) which are linear interpolated.
* If you increase this you'll ecounter big latencies, but if you
* decrease this the CPU requirements gets high.
*/
extern int SOUND_BUFFER_SIZE;
/**
* The size of ADnote Oscillator
* Decrease this => poor quality
* Increase this => CPU requirements gets high (only at start of the note)
*/
extern int OSCIL_SIZE;
/**
* The number of harmonics of additive synth
* This must be smaller than OSCIL_SIZE/2
*/
#define MAX_AD_HARMONICS 128
/**
* The number of harmonics of substractive
*/
#define MAX_SUB_HARMONICS 64
/*
* The maximum number of samples that are used for 1 PADsynth instrument(or item)
*/
#define PAD_MAX_SAMPLES 64
/*
* Number of parts
*/
#define NUM_MIDI_PARTS 16
/*
* Number of Midi channes
*/
#define NUM_MIDI_CHANNELS 16
/*
* The number of voices of additive synth for a single note
*/
#define NUM_VOICES 8
/*
* The poliphony (notes)
*/
#define POLIPHONY 60
/*
* Number of system effects
*/
#define NUM_SYS_EFX 4
/*
* Number of insertion effects
*/
#define NUM_INS_EFX 8
/*
* Number of part's insertion effects
*/
#define NUM_PART_EFX 3
/*
* Maximum number of the instrument on a part
*/
#define NUM_KIT_ITEMS 16
/*
* How is applied the velocity sensing
*/
#define VELOCITY_MAX_SCALE 8.0
/*
* The maximum length of instrument's name
*/
#define PART_MAX_NAME_LEN 30
/*
* The maximum number of bands of the equaliser
*/
#define MAX_EQ_BANDS 8
#if (MAX_EQ_BANDS >= 20)
#error "Too many EQ bands in globals.h"
#endif
/*
* Maximum filter stages
*/
#define MAX_FILTER_STAGES 5
/*
* Formant filter (FF) limits
*/
#define FF_MAX_VOWELS 6
#define FF_MAX_FORMANTS 12
#define FF_MAX_SEQUENCE 8
#define LOG_2 0.693147181
#define PI 3.1415926536
#define LOG_10 2.302585093
/*
* The threshold for the amplitude interpolation used if the amplitude
* is changed (by LFO's or Envelope's). If the change of the amplitude
* is below this, the amplitude is not interpolated
*/
#define AMPLITUDE_INTERPOLATION_THRESHOLD 0.0001
/*
* How the amplitude threshold is computed
*/
#define ABOVE_AMPLITUDE_THRESHOLD(a, b) ((2.0 * fabs((b) - (a)) \
/ (fabs((b) + (a) + 0.0000000001))) > \
AMPLITUDE_INTERPOLATION_THRESHOLD)
/*
* Interpolate Amplitude
*/
#define INTERPOLATE_AMPLITUDE(a, b, x, size) ((a) \
+ ((b) \
- (a)) * (REALTYPE)(x) \
/ (REALTYPE) (size))
/*
* dB
*/
#define dB2rap(dB) ((exp((dB) * LOG_10 / 20.0)))
#define rap2dB(rap) ((20 * log(rap) / LOG_10))
/*
* The random generator (0.0..1.0)
*/
#define RND (rand() / (RAND_MAX + 1.0))
#define ZERO(data, size) {char *data_ = (char *) data; for(int i = 0; \
i < size; \
i++) \
data_[i] = 0;}
#define ZERO_REALTYPE(data, size) {REALTYPE *data_ = (REALTYPE *) data; \
for(int i = 0; \
i < size; \
i++) \
data_[i] = 0.0;}
enum ONOFFTYPE {
OFF = 0, ON = 1
};
enum MidiControllers {
C_NULL = 0, C_pitchwheel = 1000, C_expression = 11, C_panning = 10,
C_filtercutoff = 74, C_filterq = 71, C_bandwidth = 75, C_modwheel = 1,
C_fmamp = 76,
C_volume = 7, C_sustain = 64, C_allnotesoff = 123, C_allsoundsoff = 120,
C_resetallcontrollers = 121,
C_portamento = 65, C_resonance_center = 77, C_resonance_bandwidth = 78,
C_dataentryhi = 0x06, C_dataentrylo = 0x26, C_nrpnhi = 99, C_nrpnlo = 98
};
enum LegatoMsg {
LM_Norm, LM_FadeIn, LM_FadeOut, LM_CatchUp, LM_ToNorm
};
//is like i=(int)(floor(f))
#ifdef ASM_F2I_YES
#define F2I(f, \
i) __asm__ __volatile__ ("fistpl %0" : "=m" (i) : "t" (f \
- 0.49999999) \
: "st");
#else
#define F2I(f, i) (i) = ((f > 0) ? ((int)(f)) : ((int)(f - 1.0)));
#endif
//#@# PORTING
//#ifndef O_BINARY
//#define O_BINARY 0
//#endif
#ifdef OS_WINDOWS
#define FABS(a) fabs((REALTYPE)(a))
#define SQRT(a) sqrt((REALTYPE)(a))
#define EXP(a) exp((REALTYPE)(a))
#define LOG(a) log((REALTYPE)(a))
#define POW(a, b) pow((REALTYPE)(a), (REALTYPE)(b))
#define FMOD(a, b) fmod((REALTYPE)(a), (REALTYPE)(b))
#define snprintf _snprintf
#define mkdir _mkdir
#define strcasecmp _stricmp
#define not !
//#define OSCIL_SIZE 1024
#endif
#endif