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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
|
//===========================================================================
//
// DeicsOnze2 an emulator of the YAMAHA DX11 synthesizer
//
// Version 0.5.5
//
//
//
//
// Copyright (c) 2004-2006 Nil Geisweiller
//
//
//
// 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., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA or point your web browser to http://www.gnu.org.
//===========================================================================
#ifndef __DEICSONZE2_H
#define __DEICSONZE2_H
#include <list>
#include "deicsonze2preset.h"
#include "deicsonze2gui.h"
#include "deicsonze2plugin.h"
#include "deicsonze2filter.h"
#include "libsynti/mess.h"
#include "muse/plugin.h"
#define DEICSONZE2STR "deicsonze2"
#define MAXPITCHBENDVALUE 8191
#define RESOLUTION 96000
#define MAXFXBUFFERSIZE 48000
#define NBRFXINPUTS 2
#define NBRFXOUTPUTS 2
#define NBRCTRLS 127
#define NBRPRESETS 128
#define LOWERNOTEFREQ 8.176
#define DB0LEVEL 90
#define LENGTHNAME 20
#define LENGTHCATEGORY 20
#define LENGTHSUBCATEGORY 20
#define MAXVELO 127
#define MAXVOLUME 100.0
#define MAXSTRLENGTHINITSETPATH 256
#define MAXSTRLENGTHBACKGROUNDPIXPATH 256
#define MAXSTRLENGTHFXLIB 256
#define MAXSTRLENGTHFXLABEL 256
#define DB_MIN 25.0
//coef determined by ear to sound like the YAMAHA DX11
#define COEFFEEDBACK 0.3
#define COEFPLFO(x) (x==0?0.0:(x==1?0.06:(x==2?0.12:(x==3?0.25:(x==4?0.5:(x==5?0.9:(x==6?3.9:7.9))))))) //return pitch amplitude with respect to sensitivity pitch
#define COEFALFO(x) (x==0?0.0:(x==1?0.4:(x==2?0.9:1.0)))
#define MAX(x,y) (x<y?y:x)
#define COEFLEVEL 1.0//19.0
#define COEFMAXATTACK 7.5
#define COEFERRDECSUS 0.01 //for the transition between DECAY and SUSTAIN
#define COEFERRSUSREL 0.001 //from SUSTAIN or RELEASE until no sound
//#define ERRPORTA 0.001 //dectection to stop portamento
#define COEFPORTA 0.01 //adjusted such that 10 second/octave with max porta
#define COEFPITCHENV 0.00000025 //adjust according to a real DX11....???
#define COEFDECAY 1.0
#define COEFSUSTAIN 0.2
#define COEFRELEASE 1.0
#define COEFDETUNE 0.008
#define COEFLEVELSCALE 0.0005
#define COEFGATTACK 0.9
#define COEFGRELEASE 0.9
#define LEVELSCALENOTE 24.0
#define NBRWAVES 8 //number wave forms, do not change
#define NBRBANKPRESETS 32
#define MAXNBRVOICES 64
#define NBRCHANNELS 16
#define SYSEX_INIT_DATA 1
#define SYSEX_INIT_DATA_VERSION 1
#define SAVEINITLENGTH 2
#define DEICSONZECONFIGURATIONSTR "deicsOnzeConfiguation"
#define SYSEX_MASTERVOL 4
#define MASTERVOLSTR "MasterVolume"
#define MAXMASTERVOLUME 255
#define INITMASTERVOL 192
#define SYSEX_QUALITY 5
#define QUALITYSTR "Quality"
#define HIGHSTR "High"
#define MIDDLESTR "Middle"
#define LOWSTR "Low"
#define ULTRALOWSTR "UltraLow"
#define SYSEX_FONTSIZE 6
#define FONTSIZESTR "fontSize"
#define SYSEX_SAVECONFIG 7
#define SAVECONFIGSTR "SaveConfig"
#define SYSEX_SAVEONLYUSED 8
#define SAVEONLYUSEDSTR "SaveOnlyUsed"
#define YESSTRDEI "yes"
#define NOSTRDEI "no"
#define SYSEX_LOADSET 10
#define SYSEX_ISINITSET 12
#define ISINITSETSTR "IsInitSet"
#define SYSEX_INITSETPATH 13
#define INITSETPATHSTR "InitSetPath"
#define SYSEX_ISBACKGROUNDPIX 14
#define ISBACKGROUNDPIXSTR "IsBackgroundPix"
#define SYSEX_BACKGROUNDPIXPATH 15
#define BACKGROUNDPIXPATHSTR "backgroundPixPath"
#define SYSEX_COLORGUI 20
#define TEXTCOLORSTR "TextColor"
#define BACKGROUNDCOLORSTR "BackgroundColor"
#define EDITTEXTCOLORSTR "EditTextColor"
#define EDITBACKGROUNDCOLORSTR "EditBackgroundColor"
#define COLORSYSEXLENGTH 12
#define SYSEX_UPDATESETGUI 25
#define SYSEX_PANIC 30
#define SYSEX_CHORUSACTIV 40
#define SYSEX_CHORUSPARAM 41
#define SYSEX_REVERBACTIV 60
#define SYSEX_REVERBPARAM 61
#define SYSEX_CHORUSRETURN 80
#define SYSEX_REVERBRETURN 81
#define MAXFXRETURN 255
#define INITFXRETURN 192
#define SYSEX_SELECTREVERB 82
#define SYSEX_SELECTCHORUS 83
#define SYSEX_BUILDGUIREVERB 84
#define SYSEX_BUILDGUICHORUS 85
#define SYSEX_FILTER 90
#define FILTERSTR "Filter"
#define SYSEX_DELAYACTIV 91
#define SYSEX_DELAYRETURN 92
#define SYSEX_DELAYBPM 93
#define SYSEX_DELAYBEATRATIO 94
#define SYSEX_DELAYFEEDBACK 95
#define SYSEX_DELAYLFOFREQ 96
#define SYSEX_DELAYLFODEPTH 97
//REVERB PARAMETERS
#define DEFAULTVOL 200
enum {
NUM_MASTERVOL = SAVEINITLENGTH,
NUM_CHANNEL_ENABLE,
NUM_CHANNEL_VOL = NUM_CHANNEL_ENABLE + NBRCHANNELS + 1,
NUM_CHANNEL_PAN = NUM_CHANNEL_VOL + NBRCHANNELS + 1,
NUM_CHANNEL_BRIGHTNESS = NUM_CHANNEL_PAN + NBRCHANNELS + 1,
NUM_CHANNEL_MODULATION = NUM_CHANNEL_BRIGHTNESS + 2*NBRCHANNELS +1,
NUM_CHANNEL_DETUNE = NUM_CHANNEL_MODULATION + NBRCHANNELS + 1,
NUM_CHANNEL_ATTACK = NUM_CHANNEL_DETUNE + NBRCHANNELS + 1,
NUM_CHANNEL_RELEASE = NUM_CHANNEL_ATTACK + NBRCHANNELS + 1,
NUM_CHANNEL_REVERB = NUM_CHANNEL_RELEASE + NBRCHANNELS + 1,
NUM_CHANNEL_CHORUS = NUM_CHANNEL_REVERB + NBRCHANNELS + 1,
NUM_CHANNEL_DELAY = NUM_CHANNEL_CHORUS + NBRCHANNELS + 1,
NUM_CURRENTPROG = NUM_CHANNEL_DELAY + NBRCHANNELS + 1,
NUM_CURRENTLBANK = NUM_CURRENTPROG + NBRCHANNELS + 1,
NUM_CURRENTHBANK = NUM_CURRENTLBANK + NBRCHANNELS + 1,
NUM_NBRVOICES = NUM_CURRENTHBANK + NBRCHANNELS + 1,
NUM_SAVEONLYUSED = NUM_NBRVOICES + NBRCHANNELS + 1,
NUM_SAVECONFIG,
NUM_RED_TEXT,
NUM_GREEN_TEXT,
NUM_BLUE_TEXT,
NUM_RED_BACKGROUND,
NUM_GREEN_BACKGROUND,
NUM_BLUE_BACKGROUND,
NUM_RED_EDITTEXT,
NUM_GREEN_EDITTEXT,
NUM_BLUE_EDITTEXT,
NUM_RED_EDITBACKGROUND,
NUM_GREEN_EDITBACKGROUND,
NUM_BLUE_EDITBACKGROUND,
NUM_QUALITY,
NUM_FILTER,
NUM_FONTSIZE,
NUM_ISINITSET,
NUM_INITSETPATH,
NUM_ISBACKGROUNDPIX = NUM_INITSETPATH + MAXSTRLENGTHINITSETPATH + 1,
NUM_BACKGROUNDPIXPATH,
NUM_IS_REVERB_ON = NUM_BACKGROUNDPIXPATH + MAXSTRLENGTHBACKGROUNDPIXPATH + 1,
NUM_REVERB_RETURN,
NUM_REVERB_PARAM_NBR,
NUM_REVERB_LIB,
NUM_REVERB_LABEL = NUM_REVERB_LIB + MAXSTRLENGTHFXLIB + 1,
NUM_IS_CHORUS_ON = NUM_REVERB_LABEL + MAXSTRLENGTHFXLABEL + 1,
NUM_CHORUS_RETURN,
NUM_CHORUS_PARAM_NBR,
NUM_CHORUS_LIB,
NUM_CHORUS_LABEL = NUM_CHORUS_LIB + MAXSTRLENGTHFXLIB + 1,
NUM_IS_DELAY_ON = NUM_CHORUS_LABEL + MAXSTRLENGTHFXLABEL + 1,
NUM_DELAY_RETURN,
NUM_DELAY_BPM,
NUM_DELAY_BEATRATIO = NUM_DELAY_BPM + sizeof(float),
NUM_DELAY_FEEDBACK = NUM_DELAY_BEATRATIO + sizeof(float),
NUM_DELAY_LFO_FREQ = NUM_DELAY_FEEDBACK + sizeof(float),
NUM_DELAY_LFO_DEPTH = NUM_DELAY_LFO_FREQ + sizeof(float),
NUM_CONFIGLENGTH = NUM_DELAY_LFO_DEPTH + sizeof(float)
};
class DeicsOnze2Gui;
class DeicsOnze2Plugin;
//---------------------------------------------------------
// outLevel2Amp, Amp for amplitude //between 0.0 and 2.0 or more
// 100->2.0, 90->1.0, 80->0.5 ...
//---------------------------------------------------------
inline double outLevel2Amp(int ol);
//---------------------------------------------------------
// level2amp,
// 255->0dB->1.0, 0->-27dB->0
//---------------------------------------------------------
inline double level2amp(int l);
//---------------------------------------------------------
// amp2level
// 1.0->0dB->255, 0->-27dB->0
//---------------------------------------------------------
inline int amp2level(double amp);
//---------------------------------------------------------
// amp2lowlevel
// 1.0->0dB->127, 0->-27dB->0
//---------------------------------------------------------
inline int amp2lowlevel(double amp);
//---------------------------------------------------------
// lowlevel2amp,
// 127->0dB->1.0, 0->-27dB->0
//---------------------------------------------------------
inline double lowlevel2amp(int l);
//---------------------------------------------------------
// envAR2s
// return the time in second of the ATTACK duration
//---------------------------------------------------------
inline double envAR2s(int ar);
//---------------------------------------------------------
// coefAttack
// convert the attack value to a coef for envInct
//---------------------------------------------------------
inline double coefAttack(unsigned char attack);
//---------------------------------------------------------
// envRR2coef
// return the coefficient for the exponential decrease
// with respect to rr and sampleRate, sr
//---------------------------------------------------------
inline double envRR2coef(int rr, double sr, unsigned char release);
//--------------------------------------------------------
// DeicsOnze2Ctrl
//--------------------------------------------------------
struct DeicsOnze2Ctlr
{
std::string name;
int num;
int min, max;
};
//---------------------------------------------------------
// EnvState
//---------------------------------------------------------
enum EnvState{
ATTACK,
DECAY,
SUSTAIN,
RELEASE,
OFF
};
//---------------------------------------------------------
// OpVoice
//---------------------------------------------------------
struct OpVoice {
double index;
double inct;
double targetInct; //used if portamento
double amp; //between 0 and 1
double ampVeloNote; //keeps the ratio amplitude from velo2AmpR and note2Amp
//in order to change independently the output level
//after pressing the note
EnvState envState;
double envIndex;
double envInct;
double envLevel;
double coefVLevel;
};
//---------------------------------------------------------
// PitchEnvState
//---------------------------------------------------------
enum PitchEnvState{
PHASE1,
PHASE2,
RELEASE_PE,
OFF_PE
};
//---------------------------------------------------------
// Voice
//---------------------------------------------------------
struct Voice {
bool hasAttractor;//true iff the voice has an attractor (portamento occuring)
double attractor; //contains some coeficent for portamento TODO
PitchEnvState pitchEnvState;
double pitchEnvCoefInct;
double pitchEnvCoefInctPhase1;
double pitchEnvCoefInctPhase2;
double pitchEnvCoefInctPhase3;
double pitchEnvCoefInctRelease;
double pitchEnvCoefInctInct;
bool isOn;
bool keyOn;
bool isSustained;
int pitch; //number of the note
double volume;
OpVoice op[NBROP];
float sampleFeedback;
};
//---------------------------------------------------------
// Channel
//---------------------------------------------------------
struct Channel {
bool isEnable;
float ampLeft;
float ampRight;
int volume; //0 to 255
int pan; //TODO -63 +64 or -127 +128
int modulation;//0 to 127
int detune;//-31 to 31
int brightness; //0 to 4095
int attack; //0 to 127
int release; //0 to 127
float feedbackAmp;
float lfoFreq;
float lfoPitch;
float lfoMaxCoefInct;
float lfoCoefInct;
float lfoCoefInctInct;
unsigned int lfoIndex;
unsigned int lfoMaxIndex;
float lfoMaxAmp;
float lfoMaxDAmp;
float lfoAmp;
float lfoCoefAmp;
double lfoDelayIndex;
double lfoDelayInct;
double lfoDelayMaxIndex;
bool delayPassed;
bool sustain;
double pitchBendCoef;//speed coef to read the sample
unsigned char nbrVoices;
Voice voices[MAXNBRVOICES];
double lastInc[NBROP];
std::list<int> lastVoiceKeyOn; //stack of the voice number
int lastVoiceKeyOff;
bool isLastNote;
//FX
float chorusAmount; //between 0.0 and 1.0
float reverbAmount; //between 0.0 and 1.0
float delayAmount; //between 0.0 and 1.0
};
//---------------------------------------------------------
// Global
//---------------------------------------------------------
enum Quality {
high,
middle,
low,
ultralow
};
struct Global {
float masterVolume;
Quality quality; //high, middle, low
int qualityCounter; //counter to skip some sample depending on quality
int qualityCounterTop; //number of sample - 1 to skip
double deiSampleRate; //depending on quality deicsOnze sample rate varies
bool filter; //low passe filter used when the sampling is low
int fontSize;
float lastLeftSample;
float lastRightSample;
float lastInputLeftChorusSample;
float lastInputRightChorusSample;
float lastInputLeftReverbSample;
float lastInputRightReverbSample;
float lastInputLeftDelaySample;
float lastInputRightDelaySample;
Channel channel[NBRCHANNELS];
bool isChorusActivated;
float chorusReturn;
bool isReverbActivated;
float reverbReturn;
bool isDelayActivated;
float delayReturn;
};
//---------------------------------------------------------
// DeicsOnze2 : DX11 emulator
//---------------------------------------------------------
class DeicsOnze2 : public Mess {
DeicsOnze2Gui* _gui;
static int useCount;
static float waveTable[NBRWAVES][RESOLUTION];
private:
void parseInitData(int length, const unsigned char* data);
void loadConfiguration(QString fileName);
public:
float** tempInputChorus;
float** tempOutputChorus;
float** tempInputReverb;
float** tempOutputReverb;
float** tempInputDelay;
float** tempOutputDelay;
float* getSinusWaveTable();
int nbrCtrl;
QString _initSetPath;
bool _isInitSet;
QString _backgroundPixPath;
bool _isBackgroundPix;
bool _saveOnlyUsed;
bool _saveConfig;
DeicsOnze2Ctlr _ctrl[NBRCTRLS];
Global _global;
Preset* _preset[NBRCHANNELS];
Preset* _initialPreset;
//FX
PluginI* _pluginIReverb;
PluginI* _pluginIChorus;
PluginI* _pluginIDelay;
void initPluginReverb(Plugin*);
void initPluginChorus(Plugin*);
void initPluginDelay(Plugin*);
void setReverbParam(int i, double val);
double getReverbParam(int i);
void setChorusParam(int i, double val);
double getChorusParam(int i);
void setDelayBPM(float val);
void setDelayBeatRatio(float val);
void setDelayFeedback(float val);
void setDelayLFOFreq(float val);
void setDelayLFODepth(float val);
void setDelayDryWet(float val);
float getDelayBPM();
float getDelayBeatRatio();
float getDelayFeedback();
float getDelayLFOFreq();
float getDelayLFODepth();
//Filter
LowFilter* _dryFilter;
LowFilter* _chorusFilter;
LowFilter* _reverbFilter;
LowFilter* _delayFilter;
mutable MidiPatch _patch;
mutable int _numPatchProg; //used by getPatchInfo
//preset tree
Set* _set;
void setSampleRate(int sr);
Preset* findPreset(int hbank, int lbank, int prog) const;
Subcategory* findSubcategory(int hbank, int lbank) const;
Category* findCategory(int hbank) const;
void initCtrls();
void initGlobal();
void initChannels();
void initChannel(int c);
void resetVoices(); //when panic is pressed
void initVoice(int c, int v);
void initVoices(int c);
void setPreset(int c);
void setFeedback(int c);
void setLfo(int c);
void setOutLevel(int c, int k); //set the output level of the op k
void setOutLevel(int c); //do the same for all operators
void setEnvAttack(int c, int v, int k); //set envInct of voice v and op k
void setEnvAttack(int c, int k); //do the same for all voices of operator k
void setEnvAttack(int c); //do the same for all voices all operators
void setEnvRelease(int c, int v, int k); //set coefVLevel of voice v and op k
void setEnvRelease(int c, int k); //do the same for all voices of operator k
void setEnvRelease(int c); //do the same for all voices all operators
void setPitchEnvRelease(int c, int v);
void setQuality(Quality q);
void setFilter(bool f);
double brightness2Amp(int c, int k); //get the brightness of the operator k
void loadSutulaPresets();
void loadSet(QString s);
int noteOff2Voice(int c); //return the first free voice
int minVolu2Voice(int c);
int pitchOn2Voice(int c, int pitch);
void programSelect(int c, int hbank, int lbank, int prog);
bool existsKeyOn(int ch);
void setNbrVoices(int c, int nv);
void setMasterVol(int v);
void setChannelEnable(int c, bool e);
void setChannelVol(int c, int v);
void setChannelPan(int c, int v);
void applyChannelAmp(int c);
void setChannelDetune(int c, int d);
void setChannelBrightness(int c, int b);
void setChannelModulation(int c, int m);
void setChannelAttack(int c, int a);
void setChannelRelease(int c, int r);
void setChannelReverb(int c, int r);
void setChannelChorus(int c, int val);
void setChannelDelay(int c, int val);
void setChorusReturn(int val);
void setReverbReturn(int val);
void setDelayReturn(int val);
bool getChannelEnable(int c) const;
int getNbrVoices(int c) const;
int getMasterVol(void) const;
bool getFilter(void) const;
int getChannelVol(int c) const;
int getChannelPan(int c) const;
int getChannelDetune(int c) const;
int getChannelBrightness(int c) const;
int getChannelModulation(int c) const;
int getChannelAttack(int c) const;
int getChannelRelease(int c) const;
int getChannelReverb(int c) const;
int getChannelChorus(int c) const;
int getChannelDelay(int c) const;
int getChorusReturn(void) const;
int getReverbReturn(void) const;
int getDelayReturn(void) const;
void setPitchBendCoef(int c, int val);
void setModulation(int c, int val); //TODO check between setChannelModulation
void setSustain(int c, int val);
void readConfiguration(QDomNode qdn);
void writeConfiguration(Xml* xml);
bool setController(int ch, int ctrl, int val, bool fromGui);
virtual bool setController(int ch, int ctrl, int val);
bool sysex(int length, const unsigned char* data, bool fromGui);
virtual bool sysex(int length, const unsigned char* data);
virtual const char* getPatchName(int ch, int number, int) const;
virtual const MidiPatch* getPatchInfo(int, const MidiPatch *) const;
virtual int getControllerInfo(int arg1, const char** arg2,
int* arg3, int* arg4, int* arg5);
virtual void getInitData(int* length, const unsigned char** data);
virtual bool playNote(int channel, int pitch, int velo);
virtual void process(float** buffer, int offset, int n);
// GUI interface routines
virtual bool hasGui() const { return true; }
virtual bool guiVisible() const;
virtual void showGui(bool);
virtual void getGeometry(int* x, int* y, int* w, int* h) const;
virtual void setGeometry(int, int, int, int);
DeicsOnze2();
~DeicsOnze2();
};
#endif /* __DEICSONZE2_H */
|