summaryrefslogtreecommitdiff
path: root/muse2/synti/deicsonze/deicsonzepreset.h
blob: 637350e969988c1a2c0f08c377094572b96b78d1 (plain)
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
//===========================================================================
//
//    DeicsOnze an emulator of the YAMAHA DX11 synthesizer
//
//    Version 0.5.5
//
//    deicsonzepreset.h
//
//
//  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., 51 Franklin Street, Fifth Floor, Boston, MA
// 02111-1301, USA or point your web browser to http://www.gnu.org.
//===========================================================================

#ifndef __DEICSONZEPRESET_H
#define __DEICSONZEPRESET_H

#include <vector>
#include <string>
#include "al/xml.h"
#include "muse/midictrl.h"

#define NBROP 4 //do not change
#define MAXCHARTAG 64

#define PROG_NBR 128
#define LBANK_NBR 128
#define HBANK_NBR 128

//---------------------------------------------------------
// define strings of the parameter names for load save and ctrl interface
// number of ctrl
// following the internal DX11 organization (c.f T81Z manual)
//---------------------------------------------------------
//#define CTRLOFFSET 0x100
#define CTRLOFFSET (MusECore::CTRL_NRPN14_OFFSET)
#define DECAPAR1 13
#define ARSTR "AR"
#define ARLONGSTR "AttackRate"
#define CTRL_AR 0+CTRLOFFSET
#define MAXAR 31
#define D1RSTR "D1R"
#define D1RLONGSTR "Decay1Rate"
#define CTRL_D1R 1+CTRLOFFSET
#define MAXD1R 31
#define D2RSTR "D2R"
#define D2RLONGSTR "Decay2Rate"
#define CTRL_D2R 2+CTRLOFFSET
#define MAXD2R 31
#define RRSTR "RR"
#define RRLONGSTR "ReleaseRate"
#define CTRL_RR 3+CTRLOFFSET
#define MAXRR 15
#define D1LSTR "D1L"
#define D1LLONGSTR "Decay1Level"
#define CTRL_D1L 4+CTRLOFFSET
#define MAXD1L 15
#define LSSTR "LS"
#define LSLONGSTR "LevelScaling"
#define CTRL_LS 5+CTRLOFFSET
#define MAXLS 99
#define RSSTR "RS"
#define RSLONGSTR "RateScaling"
#define CTRL_RS 6+CTRLOFFSET
#define MAXRS 3
#define EBSSTR "EBS"
#define EBSLONGSTR "EGBiasSensitivity"
#define CTRL_EBS 7+CTRLOFFSET
#define MAXEBS 7
#define AMESTR "AME"
#define AMELONGSTR "AmplitudeModulationEnable"
#define CTRL_AME 8+CTRLOFFSET
#define KVSSTR "KVS"
#define KVSLONGSTR "KeyVelocitySensitivity"
#define CTRL_KVS 9+CTRLOFFSET
#define MAXKVS 7
#define OUTSTR "OUT"
#define OUTLONGSTR "OperatorOutputLevel"
#define CTRL_OUT 10+CTRLOFFSET
#define MAXOUT 99
#define RATIOSTR "Ratio"
#define RATIOLONGSTR "Ratio"
#define CTRL_RATIO 11+CTRLOFFSET
#define MAXRATIO 64
#define DETSTR "DET"
#define DETLONGSTR "Detune"
#define CTRL_DET 12+CTRLOFFSET
#define MAXDET 3
#define ALGSTR "ALG"
#define ALGLONGSTR "Algorithm"
#define CTRL_ALG 52+CTRLOFFSET
#define MAXALG 7
#define FEEDBACKSTR "Feedback"
#define CTRL_FEEDBACK 53+CTRLOFFSET
#define MAXFEEDBACK 7
#define SPEEDSTR "Speed"
#define SPEEDLONGSTR "LFOSpeed"
#define CTRL_SPEED 54+CTRLOFFSET
#define MAXSPEED 99
#define DELAYSTR "Delay" //TODO LFOD
#define DELAYLONGSTR "LFODelay"
#define CTRL_DELAY 55+CTRLOFFSET
#define MAXDELAY 99
#define PMODDEPTHSTR "PModDepth"
#define PMODDEPTHLONGSTR "PitchModulationDepth"
#define CTRL_PMODDEPTH 56+CTRLOFFSET
#define MAXPMODDEPTH 99
#define AMODDEPTHSTR "AModDepth"
#define AMODDEPTHLONGSTR "AmplitudeModulationDepth"
#define CTRL_AMODDEPTH 57+CTRLOFFSET
#define MAXAMODDEPTH 99
#define SYNCSTR "Sync"
#define SYNCLONGSTR "LFOSync"
#define CTRL_SYNC 58+CTRLOFFSET
#define WAVESTR "Wave"
#define WAVELONGSTR "LFOWave"
#define CTRL_WAVE 59+CTRLOFFSET
#define MAXWAVE 3
#define PMODSENSSTR "PModSens"
#define PMODSENSLONGSTR "PitchModulationSensitivity"
#define CTRL_PMODSENS 60+CTRLOFFSET
#define MAXPMODSENS 7
#define AMSSTR "AMS"
#define AMSLONGSTR "AmplitudeModulationSensitivity"
#define CTRL_AMS 61+CTRLOFFSET
#define MAXAMS 3
#define TRANSPOSESTR "Transpose"
#define CTRL_TRANSPOSE 62+CTRLOFFSET
#define MAXTRANSPOSE 24
#define POLYMODESTR "PolyMode"
#define CTRL_POLYMODE 63+CTRLOFFSET
#define PBENDRANGESTR "PBendRange"
#define PBENDRANGELONGSTR "PitchBendRange"
#define CTRL_PBENDRANGE 64+CTRLOFFSET
#define MAXPBENDRANGE 12
#define PORTAMODESTR "PortaMode"
#define PORTAMODELONGSTR "PortamentoMode"
#define CTRL_PORTAMODE 65+CTRLOFFSET
#define PORTATIMESTR "PortaTime"
#define PORTATIMELONGSTR "PortamentoTime"
#define CTRL_PORTATIME 66+CTRLOFFSET
#define MAXPROTATIME 99
#define FCVOLUMESTR "FCVolume"
#define FCVOLUMELONGSTR "FootControllerVolume"
#define CTRL_FCVOLUME 67+CTRLOFFSET
#define MAXFCVOLUME 99
#define FSWSTR "FSW"
#define FSWLONGSTR "FootSwitch"
#define CTRL_FSW 68+CTRLOFFSET
#define MAXFSW 99
#define MWPITCHSTR "MWPitch"
#define MWPITCHLONGSTR "ModulationWheelPitch"
#define CTRL_MWPITCH 71+CTRLOFFSET
#define MAXMWPITCH 99
#define MWAMPLITUDESTR "MWAmplitude"
#define MWAMPLITUDELONGSTR "ModulationWheelAmplitude"
#define CTRL_MWAMPLITUDE 72+CTRLOFFSET
#define MAXMWAMPLITUDE 99
#define BCPITCHSTR "BCPitch"
#define BCPITCHLONGSTR "BreathControlPitch"
#define CTRL_BCPITCH 73+CTRLOFFSET
#define MAXBCPITCH 99
#define BCAMPLITUDESTR "BCAmplitude"
#define BCAMPLITUDELONGSTR "BreathControlAmplitude"
#define CTRL_BCAMPLITUDE 74+CTRLOFFSET
#define MAXBCAMPLITUDE 99
#define BCPITCHBIASSTR "BCPitchBias"
#define BCPITCHBIASLONGSTR "BreathControlPitchBias"
#define CTRL_BCPITCHBIAS 75+CTRLOFFSET
#define MAXBCPITCHBIAS 50
#define BCEGBIASSTR "BCEGBias"
#define BCEGBIASLONGSTR "BreathControlEGBias"
#define CTRL_BCEGBIAS 76+CTRLOFFSET
#define MAXBCEGBIAS 99
#define MIDATTACK 64
#define ATPITCHSTR "ATPitch"
#define ATPITCHLONGSTR "AfterTouchPitch"
#define CTRL_ATPITCH 77+CTRLOFFSET
#define MAXATPITCH 99
#define ATAMPLITUDESTR "ATAmplitude"
#define ATAMPLITUDELONGSTR "AfterTouchAmplitude"
#define CTRL_ATAMPLITUDE 78+CTRLOFFSET
#define MAXATAMPLITUDE 99
#define ATPITCHBIASSTR "ATPitchBias"
#define ATPITCHBIASLONGSTR "AfterTouchPitchBias"
#define CTRL_ATPITCHBIAS 79+CTRLOFFSET
#define MAXATPITCHBIAS 50
#define ATEGBIASSTR "ATEGBias"
#define ATEGBIASLONGSTR "AfterTouchEGBias"
#define CTRL_ATEGBIAS 80+CTRLOFFSET
#define MAXATEGBIAS 99
#define PR1STR "PR1"
#define PR1LONGSTR "PitchRateEG1"
#define CTRL_PR1 81+CTRLOFFSET
#define MAXPR 99
#define PR2STR "PR2"
#define PR2LONGSTR "PitchRateEG2"
#define CTRL_PR2 82+CTRLOFFSET
#define PR3STR "PR3"
#define PR3LONGSTR "PitchRateEG3"
#define CTRL_PR3 83+CTRLOFFSET
#define PL1STR "PL1"
#define PL1LONGSTR "PitchLevelEG1"
#define CTRL_PL1 84+CTRLOFFSET
#define MAXPL 99
#define PL2STR "PL2"
#define PL2LONGSTR "PitchLevelEG2"
#define CTRL_PL2 85+CTRLOFFSET
#define PL3STR "PL3"
#define PL3LONGSTR "PitchLevelEG3"
#define CTRL_PL3 86+CTRLOFFSET
#define DECAPAR2 5
#define FIXSTR "FIX"
#define FIXLONGSTR "FixedFrequency"
#define CTRL_FIX 100+CTRLOFFSET
#define FIXRANGESTR "FixRange"
#define FIXRANGELONGSTR "FixedFrequencyRange"
#define CTRL_FIXRANGE 101+CTRLOFFSET
#define MAXFIXRANGE 255
#define OSWSTR "OSW"
#define OSWLONGSTR "OperatorWaveform"
#define CTRL_OSW 103+CTRLOFFSET
#define MAXOSW 7
#define SHFTSTR "SHFT"
#define SHFTLONGSTR "EGShift"
#define CTRL_SHFT 104+CTRLOFFSET
#define MAXSHFT 3
#define REVERBRATESTR "ReverbRate"
#define CTRL_REVERBRATE 120+CTRLOFFSET
#define MAXREVERBRATE 7
#define FCPITCHSTR "FCPitch"
#define FCPITCHLONGSTR "FootControllerPitch"
#define CTRL_FCPITCH 121+CTRLOFFSET
#define MAXFCPITCH 99
#define FCAMPLITUDESTR "FCAmplitude"
#define FCAMPLITUDELONGSTR "FootControllerAmplitude"
#define CTRL_FCAMPLITUDE 122+CTRLOFFSET
#define MAXFCAMPLITUDE 99
#define CHANNELPANSTR "ChannelPan"
#define CTRL_CHANNELPAN 123+CTRLOFFSET
#define MAXCHANNELPAN 127
#define CHANNELDETUNESTR "ChannelDetune"
#define CTRL_CHANNELDETUNE 124+CTRLOFFSET
#define MAXCHANNELDETUNE 63
#define CHANNELVOLUMESTR "ChannelVolume"
#define CTRL_CHANNELVOLUME 125+CTRLOFFSET
#define MAXCHANNELVOLUME 255
#define FINEBRIGHTNESSSTR "FineBrightness"
#define CTRL_FINEBRIGHTNESS 126+CTRLOFFSET
#define MAXFINEBRIGHTNESS 4095
#define MIDFINEBRIGHTNESS (MAXFINEBRIGHTNESS+1)/2
#define BRIGHTNESSSTR "Brightness"
#define MAXBRIGHTNESS 127
#define MIDBRIGHTNESS 64
#define MAXMODULATION 127
#define MODULATIONSTR "Modulation"
#define ATTACKSTR "Attack"
#define MAXATTACK 127
#define MIDATTACK 64
#define RELEASESTR "Attack"
#define MAXRELEASE 127
#define MIDRELEASE 64
#define NBRVOICESSTR "NumberOfVoices"
#define MINNBRVOICES 1
#define CTRL_NBRVOICES 127+CTRLOFFSET
#define CHANNELENABLESTR "ChannelEnable"
#define MAXCHANNELENABLE 1
#define MINCHANNELENABLE 0
#define CTRL_CHANNELENABLE 128+CTRLOFFSET

class Preset;
class Subcategory;
class Category;
class Set;

//---------------------------------------------------------
// Algorithm
//---------------------------------------------------------

enum Algorithm {
  FIRST, // Op 0 modulated by Op 1 modulated by Op 2 modulated by Op3
  SECOND, // Op 0 modulated by Op 1 modulated by both Op 2 and Op 3
  THIRD, // Op 0 modulated by both Op 3 and Op 1 modulated by Op 2
  FOURTH, // Op 0 modulated by both Op 1 and Op 2 modulated by Op 3
  FIFTH, // (Op 0 modulated by Op 1) add to (Op 2 modulated by Op 3)
  SIXTH, // addition of the three Op 0, 1, 2 all modulated by Op 3
  SEVENTH, // addition of the three Op 0, 1, 2 with 2 modulated by Op3
  EIGHTH // addition of the four Op 0, 1, 2, 3
};

//---------------------------------------------------------
// Wave of the low frequency modulation
//---------------------------------------------------------
enum Wave {
  SAWUP,
  SQUARE,
  TRIANGL,
  SHOLD
};

//---------------------------------------------------------
// Lfo, low frequency modulation
//---------------------------------------------------------
struct Lfo {
  Wave wave;
  unsigned char speed; //0 to 99
  unsigned char delay; //0 to 99
  unsigned char pModDepth; //0 to 99
  unsigned char aModDepth; //0 to 99
  bool sync;
};

//---------------------------------------------------------
// Sensitivity
//  of the frequency and amplitude of the lfo
//  and the key velocity
//---------------------------------------------------------
struct Sensitivity {
  unsigned char pitch; //0 to 7
  unsigned char amplitude; //0 to 3
  bool ampOn[NBROP];
  unsigned char egBias[NBROP]; //O to 7
  unsigned char keyVelocity[NBROP]; //0 to 7
};

//---------------------------------------------------------
// Frequency
//---------------------------------------------------------
struct Frequency {
  double ratio;
  bool isFix; //if isFix no ratio but frequency
  double freq;
};

//---------------------------------------------------------
// OscWave
//---------------------------------------------------------
enum OscWave {
  W1, //sine wave
  W2, //sine� relative
  W3, //half sine
  W4, //half sine� relative
  W5,
  W6,
  W7,
  W8
};

enum egShiftValue {VOF, V48, V24, V12};

//---------------------------------------------------------
// Eg
//  Envelope
//---------------------------------------------------------
struct Eg {
  unsigned char ar; //0 to 31 speed attack
  unsigned char d1r; //0 to 31 speed decay
  unsigned char d1l; //0 to 15 level sustain
  unsigned char d2r; //0 to 31 speed of sustain
  unsigned char rr; //1 to 15
  egShiftValue egShift;
};

//---------------------------------------------------------
// PitchEg
//---------------------------------------------------------
struct PitchEg {
  unsigned char pr1;//0 to 99
  unsigned char pr2;//0 to 99
  unsigned char pr3;//0 to 99
  unsigned char pl1;//0 to 99
  unsigned char pl2;//0 to 99
  unsigned char pl3;//0 to 99
};

//---------------------------------------------------------
// Scaling
//---------------------------------------------------------
struct Scaling {
  unsigned char rate[NBROP];//0 to 3
  unsigned char level[NBROP];//0 to 99
};

//---------------------------------------------------------
// Mode
//---------------------------------------------------------
enum Mode {
  POLY,
  MONO
};

//---------------------------------------------------------
// Portamento
//---------------------------------------------------------
enum Portamento {
  FINGER,
  FULL
};

//---------------------------------------------------------
// FootSw
//---------------------------------------------------------
enum FootSw {
  POR,
  SUS
};
//---------------------------------------------------------
// Function
//---------------------------------------------------------
struct Function {
  int transpose;
  Mode mode;
  unsigned char pBendRange;//0 to 12
  Portamento portamento;
  unsigned char portamentoTime;//0 to 99
  FootSw footSw;
  unsigned char fcVolume;//0 to 99
  unsigned char fcPitch;//0 to 99
  unsigned char fcAmplitude;//0 to 99
  unsigned char mwPitch;//0 to 99
  unsigned char mwAmplitude;//0 to 99
  unsigned char bcPitch;//0 to 99
  unsigned char bcAmplitude;//0 to 99
  signed char bcPitchBias;//-50 to 50
  unsigned char bcEgBias;//0 to 99
  unsigned char atPitch;//0 to 99
  unsigned char atAmplitude;//0 to 99
  signed char atPitchBias;//-50 to 50
  unsigned char atEgBias;//0 to 99
  signed char reverbRate;//O=off, 1 to 7
};

//---------------------------------------------------------
// Preset class
//---------------------------------------------------------

class Preset {
 public:
    Subcategory* _subcategory; //subcategory parent
    bool _isUsed; //false if the preset has never been used or modified,
                  //in this case the preset is not going to be
                  //save with the project
    //Attributes
    Algorithm algorithm;
    unsigned char feedback; //0 to 7
    Lfo lfo;
    Sensitivity sensitivity;
    Frequency frequency[NBROP];
    OscWave oscWave[NBROP];
    signed char detune[NBROP]; //-3 to 3
    Eg eg[NBROP];
    PitchEg pitchEg;
    unsigned char outLevel[NBROP]; //0 to 99
    Scaling scaling;
    Function function;
    //int globalDetune; //-31 to 31 //now to the channel
    std::string name;
    //unsigned char modulation; //0 to 127
    int prog; //0 to 127
    //Methods
    void printPreset();
    void initPreset();
    void readPreset(QDomNode qdn);
    void writePreset(AL::Xml* xml, bool onlyUsed);
    void linkSubcategory(Subcategory* sub);
    void merge(Preset* p); //copy the data of p in the preset
    void setIsUsed(bool b); //set flag _isUsed and transmit in the parents
    void getHBankLBankProg(int* h, int* l, int* p); //return the hbank, lbank and prog of the preset
    //Constructor destructor
    Preset();
    Preset(Subcategory* sub);
    Preset(Subcategory* sub, int prog);
    ~Preset();
};

//---------------------------------------------------------------
// Bank, organized by a tree of category, subcategory, preset
//---------------------------------------------------------------
class Subcategory {
 public:
    Category* _category;//parent category
    bool _isUsed; //false if the subcategory has never been used or modified,
                  //in this case the subcategory is not going to be
                  //save with the project
    std::string _subcategoryName;
    int _lbank; //0 to 127
    std::vector<Preset*> _presetVector;
    Preset* findPreset(int prog);
    void readSubcategory(QDomNode subNode);
    void writeSubcategory(AL::Xml* xml, bool onlyUsed);
    void printSubcategory();
    void linkCategory(Category* cat);
    void unlink();
    bool isFreeProg(int prog);
    int firstFreeProg();
    void merge(Preset*);
    //Constructor destructor
    Subcategory();
    Subcategory(Category* cat);
    Subcategory(const std::string name);
    Subcategory(Category* cat, const std::string name, int lbank);
    ~Subcategory();
};

class Category {
 public:
    Set* _set;//parent set
    bool _isUsed; //false if the category has never been used or modified,
                  //in this case the category is not going to be
                  //save with the project
    std::string _categoryName;
    int _hbank; //0 to 127
    std::vector<Subcategory*> _subcategoryVector;
    Subcategory* findSubcategory(int lbank);
    Preset* findPreset(int lbank, int prog);
    void readCategory(QDomNode catNode);
    void writeCategory(AL::Xml* xml, bool onlyUsed);
    void printCategory();
    void linkSet(Set* s);
    void unlink();
    bool isFreeLBank(int lbank);
    int firstFreeLBank(); //return -1 if no free
    void merge(Subcategory*);
    //Constructor Destructor
    Category();
    Category(Set* s);
    Category(Set* s,const std::string name, int hbank);
    ~Category();
};

class Set {
 public:
    std::string _setName;
    std::vector<Category*> _categoryVector;
    Preset* findPreset(int hbank, int lbank, int prog);
    Subcategory* findSubcategory(int hbank, int lbank);
    Category* findCategory(int hbank);
    void readSet(QDomNode setNode);
    void writeSet(AL::Xml* xml, bool onlyUsed);
    void printSet();
    bool isFreeHBank(int hbank);
    int firstFreeHBank();
    void merge(Category*);
    //Constructor Destructor
    Set(const std::string name){_setName=name;}
    ~Set() {
	while(!_categoryVector.empty()) delete(*_categoryVector.begin());
    }
};

#endif /* __DEICSONZE_H */