LMMS
Loading...
Searching...
No Matches
globals.h
Go to the documentation of this file.
1/*
2 ZynAddSubFX - a software synthesizer
3
4 globals.h - it contains program settings and the program capabilities
5 like number of parts, of effects
6 Copyright (C) 2002-2005 Nasca Octavian Paul
7 Author: Nasca Octavian Paul
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13*/
14
15
16#ifndef GLOBALS_H
17#define GLOBALS_H
18
19#if defined(__clang__)
20#define REALTIME __attribute__((annotate("realtime")))
21#define NONREALTIME __attribute__((annotate("nonrealtime")))
22#else
23#define REALTIME
24#define NONREALTIME
25#endif
26
27//Forward Declarations
28
29#if defined(__APPLE__) || defined(__FreeBSD__)
30#include <complex>
31#else
32namespace std {
33 template<class T> struct complex;
34}
35#endif
36
37namespace rtosc{struct Ports; struct ClonePorts; struct MergePorts; class ThreadLink;}
38namespace zyncarla {
39
40class EffectMgr;
45class SynthNote;
46
47class Allocator;
48class AbsTime;
49class RelTime;
50
51class Microtonal;
52class XMLwrapper;
53class Resonance;
54class FFTwrapper;
55class EnvelopeParams;
56class LFOParams;
57class FilterParams;
58
59struct WatchManager;
60class LFO;
61class Envelope;
62class OscilGen;
63
64class Controller;
65class Master;
66class Part;
67
68class Filter;
69class AnalogFilter;
70class SVFilter;
71class FormantFilter;
72class ModFilter;
73
74typedef double fftw_real;
76
81#define MAX_AD_HARMONICS 128
82
83
87#define MAX_SUB_HARMONICS 64
88
89
90/*
91 * The maximum number of samples that are used for 1 PADsynth instrument(or item)
92 */
93#define PAD_MAX_SAMPLES 64
94
95
96/*
97 * Number of parts
98 */
99#define NUM_MIDI_PARTS 16
100
101/*
102 * Number of Midi channes
103 */
104#define NUM_MIDI_CHANNELS 16
105
106/*
107 * The number of voices of additive synth for a single note
108 */
109#define NUM_VOICES 8
110
111/*
112 * The polyphony (notes)
113 */
114#define POLYPHONY 60
115
116/*
117 * Number of system effects
118 */
119#define NUM_SYS_EFX 4
120
121
122/*
123 * Number of insertion effects
124 */
125#define NUM_INS_EFX 8
126
127/*
128 * Number of part's insertion effects
129 */
130#define NUM_PART_EFX 3
131
132/*
133 * Maximum number of the instrument on a part
134 */
135#define NUM_KIT_ITEMS 16
136
137
138/*
139 * How is applied the velocity sensing
140 */
141#define VELOCITY_MAX_SCALE 8.0f
142
143/*
144 * The maximum length of instrument's name
145 */
146#define PART_MAX_NAME_LEN 30
147
148/*
149 * The maximum we allow for an XMZ path
150 *
151 * Note that this is an ugly hack. Finding a compile time path
152 * max portably is painful.
153 */
154#define XMZ_PATH_MAX 1024
155
156/*
157 * The maximum number of bands of the equaliser
158 */
159#define MAX_EQ_BANDS 8
160#if (MAX_EQ_BANDS >= 20)
161#error "Too many EQ bands in globals.h"
162#endif
163
164
165/*
166 * Maximum filter stages
167 */
168#define MAX_FILTER_STAGES 5
169
170/*
171 * Formant filter (FF) limits
172 */
173#define FF_MAX_VOWELS 6
174#define FF_MAX_FORMANTS 12
175#define FF_MAX_SEQUENCE 8
176
177#define MAX_PRESETTYPE_SIZE 30
178
179#define LOG_2 0.693147181f
180#define PI 3.1415926536f
181#define LOG_10 2.302585093f
182
183/*
184 * For de-pop adjustment
185 */
186#define FADEIN_ADJUSTMENT_SCALE 20
187
188/*
189 * Envelope Limits
190 */
191#define MAX_ENVELOPE_POINTS 40
192#define MIN_ENVELOPE_DB -400
193
194/*
195 * The threshold for the amplitude interpolation used if the amplitude
196 * is changed (by LFO's or Envelope's). If the change of the amplitude
197 * is below this, the amplitude is not interpolated
198 */
199#define AMPLITUDE_INTERPOLATION_THRESHOLD 0.0001f
200
201/*
202 * How the amplitude threshold is computed
203 */
204#define ABOVE_AMPLITUDE_THRESHOLD(a, b) ((2.0f * fabs((b) - (a)) \
205 / (fabs((b) + (a) \
206 + 0.0000000001f))) > \
207 AMPLITUDE_INTERPOLATION_THRESHOLD)
208
209/*
210 * Interpolate Amplitude
211 */
212#define INTERPOLATE_AMPLITUDE(a, b, x, size) ((a) \
213 + ((b) \
214 - (a)) * (float)(x) \
215 / (float) (size))
216
217
218/*
219 * dB
220 */
221#define dB2rap(dB) ((expf((dB) * LOG_10 / 20.0f)))
222#define rap2dB(rap) ((20 * logf(rap) / LOG_10))
223
224#define ZERO(data, size) {char *data_ = (char *) data; for(int i = 0; \
225 i < size; \
226 i++) \
227 data_[i] = 0; }
228#define ZERO_float(data, size) {float *data_ = (float *) data; \
229 for(int i = 0; \
230 i < size; \
231 i++) \
232 data_[i] = 0.0f; }
233
235 OFF = 0, ON = 1
236};
237
249
253
254//is like i=(int)(floor(f))
255#ifdef ASM_F2I_YES
256#define F2I(f, \
257 i) __asm__ __volatile__ ("fistpl %0" : "=m" (i) : "t" (f \
258 - \
259 0.49999999f) \
260 : "st");
261#else
262#define F2I(f, i) (i) = ((f > 0) ? ((int)(f)) : ((int)(f - 1.0f)));
263#endif
264
265
266
267#ifndef O_BINARY
268#define O_BINARY 0
269#endif
270
271template<class T>
273{
274 T* ptr = nullptr;
275public:
276 m_unique_ptr() = default;
278 ptr = other.ptr;
279 other.ptr = nullptr;
280 }
281 m_unique_ptr(const m_unique_ptr& other) = delete;
282 ~m_unique_ptr() { ptr = nullptr; }
283 void resize(unsigned sz) {
284 delete[] ptr;
285 ptr = new T[sz]; }
286
287 operator T*() { return ptr; }
288 operator const T*() const { return ptr; }
289 //T& operator[](unsigned idx) { return ptr[idx]; }
290 //const T& operator[](unsigned idx) const { return ptr[idx]; }
291};
292
293//temporary include for synth->{samplerate/buffersize} members
294struct SYNTH_T {
295
297 :samplerate(44100), buffersize(256), oscilsize(1024)
298 {
299 alias(false);
300 }
301
302 SYNTH_T(const SYNTH_T& ) = delete;
303 SYNTH_T(SYNTH_T&& ) = default;
304
307
309 unsigned int samplerate;
310
320
327
328 //Alias for above terms
334
335 float dt(void) const
336 {
337 return buffersize_f / samplerate_f;
338 }
339 void alias(bool randomize=true);
340 static float numRandom(void); //defined in Util.cpp for now
341};
342
343}
344#endif
Definition ADnoteParameters.h:292
Definition AnalogFilter.h:35
Definition Controller.h:9
Definition EffectMgr.h:44
Definition EnvelopeParams.h:34
Definition FFTwrapper.h:32
Definition FilterParams.h:31
Definition FormantFilter.h:31
Definition LFO.h:31
Definition LFOParams.h:30
Definition Master.h:55
Definition Microtonal.h:37
Definition OscilGen.h:33
Definition PADnoteParameters.h:41
Definition Part.h:45
Definition Resonance.h:34
Definition SUBnoteParameters.h:33
Definition SVFilter.h:30
Definition SynthNote.h:28
Definition globals.h:273
~m_unique_ptr()
Definition globals.h:282
m_unique_ptr(const m_unique_ptr &other)=delete
void resize(unsigned sz)
Definition globals.h:283
m_unique_ptr(m_unique_ptr &&other)
Definition globals.h:277
T * ptr
Definition globals.h:274
Definition globals.h:37
Definition juce_Uuid.h:141
Definition zynaddsubfx-src.cpp:569
MidiControllers
Definition globals.h:238
@ C_modwheel
Definition globals.h:241
@ C_expression
Definition globals.h:240
@ C_filterq
Definition globals.h:241
@ C_portamento
Definition globals.h:245
@ C_sustain
Definition globals.h:243
@ C_resetallcontrollers
Definition globals.h:244
@ C_panning
Definition globals.h:240
@ C_dataentrylo
Definition globals.h:247
@ C_filtercutoff
Definition globals.h:241
@ C_resonance_center
Definition globals.h:245
@ C_allnotesoff
Definition globals.h:243
@ C_allsoundsoff
Definition globals.h:243
@ C_bankselectlsb
Definition globals.h:240
@ C_dataentryhi
Definition globals.h:247
@ C_nrpnhi
Definition globals.h:247
@ C_pitchwheel
Definition globals.h:239
@ C_volume
Definition globals.h:243
@ C_nrpnlo
Definition globals.h:247
@ C_resonance_bandwidth
Definition globals.h:245
@ C_bankselectmsb
Definition globals.h:239
@ C_fmamp
Definition globals.h:242
@ C_bandwidth
Definition globals.h:241
@ C_NULL
Definition globals.h:239
double fftw_real
Definition globals.h:74
std::complex< fftw_real > fft_t
Definition globals.h:75
LegatoMsg
Definition globals.h:250
@ LM_ToNorm
Definition globals.h:251
@ LM_Norm
Definition globals.h:251
@ LM_FadeOut
Definition globals.h:251
@ LM_FadeIn
Definition globals.h:251
@ LM_CatchUp
Definition globals.h:251
ONOFFTYPE
Definition globals.h:234
@ ON
Definition globals.h:235
@ OFF
Definition globals.h:235
Definition ADnoteParameters.h:47
Definition analogue.cpp:67
Definition audio-gain.c:30
Definition ports.h:246
Definition ports.h:252
Definition ports.h:161
Definition globals.h:33
int bufferbytes
Definition globals.h:332
float dt(void) const
Definition globals.h:335
float samplerate_f
Definition globals.h:329
float halfsamplerate_f
Definition globals.h:330
unsigned int samplerate
Definition globals.h:309
static float numRandom(void)
Definition Util.cpp:211
SYNTH_T(const SYNTH_T &)=delete
m_unique_ptr< float > denormalkillbuf
Definition globals.h:306
void alias(bool randomize=true)
Definition globals.cpp:20
float oscilsize_f
Definition globals.h:333
int oscilsize
Definition globals.h:326
SYNTH_T(SYNTH_T &&)=default
int buffersize
Definition globals.h:319
float buffersize_f
Definition globals.h:331
SYNTH_T(void)
Definition globals.h:296