1 //=========================================================================== 2 // 3 // DeicsOnze an emulator of the YAMAHA DX11 synthesizer 4 // 5 // Version 0.5.5 6 // 7 // deicsonzepreset.h 8 // 9 // 10 // Copyright (c) 2004-2006 Nil Geisweiller 11 // 12 // 13 // 14 // This program is free software; you can redistribute it and/or 15 // modify it under the terms of the GNU General Public License 16 // as published by the Free Software Foundation; either version 2 17 // of the License, or (at your option) any later version. 18 // 19 // This program is distributed in the hope that it will be useful, 20 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 // GNU General Public License for more details. 23 // 24 // You should have received a copy of the GNU General Public License 25 // along with this program; if not, write to the Free Software 26 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 27 // 02111-1301, USA or point your web browser to http://www.gnu.org. 28 //=========================================================================== 29 30 #ifndef __DEICSONZEPRESET_H 31 #define __DEICSONZEPRESET_H 32 33 #include <vector> 34 #include <string> 35 #include "al/xml.h" 36 #include "midictrl_consts.h" 37 38 #define NBROP 4 //do not change 39 #define MAXCHARTAG 256 40 41 #define PROG_NBR 128 42 #define LBANK_NBR 128 43 #define HBANK_NBR 128 44 45 //--------------------------------------------------------- 46 // define strings of the parameter names for load save and ctrl interface 47 // number of ctrl 48 // following the internal DX11 organization (c.f T81Z manual) 49 //--------------------------------------------------------- 50 //#define CTRLOFFSET 0x100 51 #define CTRLOFFSET (MusECore::CTRL_NRPN14_OFFSET) 52 #define DECAPAR1 13 53 #define ARSTR "AR" 54 #define ARLONGSTR "AttackRate" 55 #define CTRL_AR 0+CTRLOFFSET 56 #define MAXAR 31 57 #define D1RSTR "D1R" 58 #define D1RLONGSTR "Decay1Rate" 59 #define CTRL_D1R 1+CTRLOFFSET 60 #define MAXD1R 31 61 #define D2RSTR "D2R" 62 #define D2RLONGSTR "Decay2Rate" 63 #define CTRL_D2R 2+CTRLOFFSET 64 #define MAXD2R 31 65 #define RRSTR "RR" 66 #define RRLONGSTR "ReleaseRate" 67 #define CTRL_RR 3+CTRLOFFSET 68 #define MAXRR 15 69 #define D1LSTR "D1L" 70 #define D1LLONGSTR "Decay1Level" 71 #define CTRL_D1L 4+CTRLOFFSET 72 #define MAXD1L 15 73 #define LSSTR "LS" 74 #define LSLONGSTR "LevelScaling" 75 #define CTRL_LS 5+CTRLOFFSET 76 #define MAXLS 99 77 #define RSSTR "RS" 78 #define RSLONGSTR "RateScaling" 79 #define CTRL_RS 6+CTRLOFFSET 80 #define MAXRS 3 81 #define EBSSTR "EBS" 82 #define EBSLONGSTR "EGBiasSensitivity" 83 #define CTRL_EBS 7+CTRLOFFSET 84 #define MAXEBS 7 85 #define AMESTR "AME" 86 #define AMELONGSTR "AmplitudeModulationEnable" 87 #define CTRL_AME 8+CTRLOFFSET 88 #define KVSSTR "KVS" 89 #define KVSLONGSTR "KeyVelocitySensitivity" 90 #define CTRL_KVS 9+CTRLOFFSET 91 #define MAXKVS 7 92 #define OUTSTR "OUT" 93 #define OUTLONGSTR "OperatorOutputLevel" 94 #define CTRL_OUT 10+CTRLOFFSET 95 #define MAXOUT 99 96 #define RATIOSTR "Ratio" 97 #define RATIOLONGSTR "Ratio" 98 #define CTRL_RATIO 11+CTRLOFFSET 99 #define MAXRATIO 64 100 #define DETSTR "DET" 101 #define DETLONGSTR "Detune" 102 #define CTRL_DET 12+CTRLOFFSET 103 #define MAXDET 3 104 #define ALGSTR "ALG" 105 #define ALGLONGSTR "Algorithm" 106 #define CTRL_ALG 52+CTRLOFFSET 107 #define MAXALG 7 108 #define FEEDBACKSTR "Feedback" 109 #define CTRL_FEEDBACK 53+CTRLOFFSET 110 #define MAXFEEDBACK 7 111 #define SPEEDSTR "Speed" 112 #define SPEEDLONGSTR "LFOSpeed" 113 #define CTRL_SPEED 54+CTRLOFFSET 114 #define MAXSPEED 99 115 #define DELAYSTR "Delay" //TODO LFOD 116 #define DELAYLONGSTR "LFODelay" 117 #define CTRL_DELAY 55+CTRLOFFSET 118 #define MAXDELAY 99 119 #define PMODDEPTHSTR "PModDepth" 120 #define PMODDEPTHLONGSTR "PitchModulationDepth" 121 #define CTRL_PMODDEPTH 56+CTRLOFFSET 122 #define MAXPMODDEPTH 99 123 #define AMODDEPTHSTR "AModDepth" 124 #define AMODDEPTHLONGSTR "AmplitudeModulationDepth" 125 #define CTRL_AMODDEPTH 57+CTRLOFFSET 126 #define MAXAMODDEPTH 99 127 #define SYNCSTR "Sync" 128 #define SYNCLONGSTR "LFOSync" 129 #define CTRL_SYNC 58+CTRLOFFSET 130 #define WAVESTR "Wave" 131 #define WAVELONGSTR "LFOWave" 132 #define CTRL_WAVE 59+CTRLOFFSET 133 #define MAXWAVE 3 134 #define PMODSENSSTR "PModSens" 135 #define PMODSENSLONGSTR "PitchModulationSensitivity" 136 #define CTRL_PMODSENS 60+CTRLOFFSET 137 #define MAXPMODSENS 7 138 #define AMSSTR "AMS" 139 #define AMSLONGSTR "AmplitudeModulationSensitivity" 140 #define CTRL_AMS 61+CTRLOFFSET 141 #define MAXAMS 3 142 #define TRANSPOSESTR "Transpose" 143 #define CTRL_TRANSPOSE 62+CTRLOFFSET 144 #define MAXTRANSPOSE 24 145 #define POLYMODESTR "PolyMode" 146 #define CTRL_POLYMODE 63+CTRLOFFSET 147 #define PBENDRANGESTR "PBendRange" 148 #define PBENDRANGELONGSTR "PitchBendRange" 149 #define CTRL_PBENDRANGE 64+CTRLOFFSET 150 #define MAXPBENDRANGE 12 151 #define PORTAMODESTR "PortaMode" 152 #define PORTAMODELONGSTR "PortamentoMode" 153 #define CTRL_PORTAMODE 65+CTRLOFFSET 154 #define PORTATIMESTR "PortaTime" 155 #define PORTATIMELONGSTR "PortamentoTime" 156 #define CTRL_PORTATIME 66+CTRLOFFSET 157 #define MAXPROTATIME 99 158 #define FCVOLUMESTR "FCVolume" 159 #define FCVOLUMELONGSTR "FootControllerVolume" 160 #define CTRL_FCVOLUME 67+CTRLOFFSET 161 #define MAXFCVOLUME 99 162 #define FSWSTR "FSW" 163 #define FSWLONGSTR "FootSwitch" 164 #define CTRL_FSW 68+CTRLOFFSET 165 #define MAXFSW 99 166 #define MWPITCHSTR "MWPitch" 167 #define MWPITCHLONGSTR "ModulationWheelPitch" 168 #define CTRL_MWPITCH 71+CTRLOFFSET 169 #define MAXMWPITCH 99 170 #define MWAMPLITUDESTR "MWAmplitude" 171 #define MWAMPLITUDELONGSTR "ModulationWheelAmplitude" 172 #define CTRL_MWAMPLITUDE 72+CTRLOFFSET 173 #define MAXMWAMPLITUDE 99 174 #define BCPITCHSTR "BCPitch" 175 #define BCPITCHLONGSTR "BreathControlPitch" 176 #define CTRL_BCPITCH 73+CTRLOFFSET 177 #define MAXBCPITCH 99 178 #define BCAMPLITUDESTR "BCAmplitude" 179 #define BCAMPLITUDELONGSTR "BreathControlAmplitude" 180 #define CTRL_BCAMPLITUDE 74+CTRLOFFSET 181 #define MAXBCAMPLITUDE 99 182 #define BCPITCHBIASSTR "BCPitchBias" 183 #define BCPITCHBIASLONGSTR "BreathControlPitchBias" 184 #define CTRL_BCPITCHBIAS 75+CTRLOFFSET 185 #define MAXBCPITCHBIAS 50 186 #define BCEGBIASSTR "BCEGBias" 187 #define BCEGBIASLONGSTR "BreathControlEGBias" 188 #define CTRL_BCEGBIAS 76+CTRLOFFSET 189 #define MAXBCEGBIAS 99 190 #define MIDATTACK 64 191 #define ATPITCHSTR "ATPitch" 192 #define ATPITCHLONGSTR "AfterTouchPitch" 193 #define CTRL_ATPITCH 77+CTRLOFFSET 194 #define MAXATPITCH 99 195 #define ATAMPLITUDESTR "ATAmplitude" 196 #define ATAMPLITUDELONGSTR "AfterTouchAmplitude" 197 #define CTRL_ATAMPLITUDE 78+CTRLOFFSET 198 #define MAXATAMPLITUDE 99 199 #define ATPITCHBIASSTR "ATPitchBias" 200 #define ATPITCHBIASLONGSTR "AfterTouchPitchBias" 201 #define CTRL_ATPITCHBIAS 79+CTRLOFFSET 202 #define MAXATPITCHBIAS 50 203 #define ATEGBIASSTR "ATEGBias" 204 #define ATEGBIASLONGSTR "AfterTouchEGBias" 205 #define CTRL_ATEGBIAS 80+CTRLOFFSET 206 #define MAXATEGBIAS 99 207 #define PR1STR "PR1" 208 #define PR1LONGSTR "PitchRateEG1" 209 #define CTRL_PR1 81+CTRLOFFSET 210 #define MAXPR 99 211 #define PR2STR "PR2" 212 #define PR2LONGSTR "PitchRateEG2" 213 #define CTRL_PR2 82+CTRLOFFSET 214 #define PR3STR "PR3" 215 #define PR3LONGSTR "PitchRateEG3" 216 #define CTRL_PR3 83+CTRLOFFSET 217 #define PL1STR "PL1" 218 #define PL1LONGSTR "PitchLevelEG1" 219 #define CTRL_PL1 84+CTRLOFFSET 220 #define MAXPL 99 221 #define PL2STR "PL2" 222 #define PL2LONGSTR "PitchLevelEG2" 223 #define CTRL_PL2 85+CTRLOFFSET 224 #define PL3STR "PL3" 225 #define PL3LONGSTR "PitchLevelEG3" 226 #define CTRL_PL3 86+CTRLOFFSET 227 #define DECAPAR2 5 228 #define FIXSTR "FIX" 229 #define FIXLONGSTR "FixedFrequency" 230 #define CTRL_FIX 100+CTRLOFFSET 231 #define FIXRANGESTR "FixRange" 232 #define FIXRANGELONGSTR "FixedFrequencyRange" 233 #define CTRL_FIXRANGE 101+CTRLOFFSET 234 #define MAXFIXRANGE 255 235 #define OSWSTR "OSW" 236 #define OSWLONGSTR "OperatorWaveform" 237 #define CTRL_OSW 103+CTRLOFFSET 238 #define MAXOSW 7 239 #define SHFTSTR "SHFT" 240 #define SHFTLONGSTR "EGShift" 241 #define CTRL_SHFT 104+CTRLOFFSET 242 #define MAXSHFT 3 243 #define REVERBRATESTR "ReverbRate" 244 #define CTRL_REVERBRATE 120+CTRLOFFSET 245 #define MAXREVERBRATE 7 246 #define FCPITCHSTR "FCPitch" 247 #define FCPITCHLONGSTR "FootControllerPitch" 248 #define CTRL_FCPITCH 121+CTRLOFFSET 249 #define MAXFCPITCH 99 250 #define FCAMPLITUDESTR "FCAmplitude" 251 #define FCAMPLITUDELONGSTR "FootControllerAmplitude" 252 #define CTRL_FCAMPLITUDE 122+CTRLOFFSET 253 #define MAXFCAMPLITUDE 99 254 #define CHANNELPANSTR "ChannelPan" 255 #define CTRL_CHANNELPAN 123+CTRLOFFSET 256 #define MAXCHANNELPAN 127 257 #define CHANNELDETUNESTR "ChannelDetune" 258 #define CTRL_CHANNELDETUNE 124+CTRLOFFSET 259 #define MAXCHANNELDETUNE 63 260 #define CHANNELVOLUMESTR "ChannelVolume" 261 #define CTRL_CHANNELVOLUME 125+CTRLOFFSET 262 #define MAXCHANNELVOLUME 255 263 #define FINEBRIGHTNESSSTR "FineBrightness" 264 #define CTRL_FINEBRIGHTNESS 126+CTRLOFFSET 265 #define MAXFINEBRIGHTNESS 4095 266 #define MIDFINEBRIGHTNESS (MAXFINEBRIGHTNESS+1)/2 267 #define BRIGHTNESSSTR "Brightness" 268 #define MAXBRIGHTNESS 127 269 #define MIDBRIGHTNESS 64 270 #define MAXMODULATION 127 271 #define MODULATIONSTR "Modulation" 272 #define ATTACKSTR "Attack" 273 #define MAXATTACK 127 274 #define MIDATTACK 64 275 #define RELEASESTR "Attack" 276 #define MAXRELEASE 127 277 #define MIDRELEASE 64 278 #define NBRVOICESSTR "NumberOfVoices" 279 #define MINNBRVOICES 1 280 #define CTRL_NBRVOICES 127+CTRLOFFSET 281 #define CHANNELENABLESTR "ChannelEnable" 282 #define MAXCHANNELENABLE 1 283 #define MINCHANNELENABLE 0 284 #define CTRL_CHANNELENABLE 128+CTRLOFFSET 285 286 class Preset; 287 class Subcategory; 288 class Category; 289 class Set; 290 291 //--------------------------------------------------------- 292 // Algorithm 293 //--------------------------------------------------------- 294 295 enum Algorithm { 296 FIRST, // Op 0 modulated by Op 1 modulated by Op 2 modulated by Op3 297 SECOND, // Op 0 modulated by Op 1 modulated by both Op 2 and Op 3 298 THIRD, // Op 0 modulated by both Op 3 and Op 1 modulated by Op 2 299 FOURTH, // Op 0 modulated by both Op 1 and Op 2 modulated by Op 3 300 FIFTH, // (Op 0 modulated by Op 1) add to (Op 2 modulated by Op 3) 301 SIXTH, // addition of the three Op 0, 1, 2 all modulated by Op 3 302 SEVENTH, // addition of the three Op 0, 1, 2 with 2 modulated by Op3 303 EIGHTH // addition of the four Op 0, 1, 2, 3 304 }; 305 306 //--------------------------------------------------------- 307 // Wave of the low frequency modulation 308 //--------------------------------------------------------- 309 enum Wave { 310 SAWUP, 311 SQUARE, 312 TRIANGL, 313 SHOLD 314 }; 315 316 //--------------------------------------------------------- 317 // Lfo, low frequency modulation 318 //--------------------------------------------------------- 319 struct Lfo { 320 Wave wave; 321 unsigned char speed; //0 to 99 322 unsigned char delay; //0 to 99 323 unsigned char pModDepth; //0 to 99 324 unsigned char aModDepth; //0 to 99 325 bool sync; 326 }; 327 328 //--------------------------------------------------------- 329 // Sensitivity 330 // of the frequency and amplitude of the lfo 331 // and the key velocity 332 //--------------------------------------------------------- 333 struct Sensitivity { 334 unsigned char pitch; //0 to 7 335 unsigned char amplitude; //0 to 3 336 bool ampOn[NBROP]; 337 unsigned char egBias[NBROP]; //O to 7 338 unsigned char keyVelocity[NBROP]; //0 to 7 339 }; 340 341 //--------------------------------------------------------- 342 // Frequency 343 //--------------------------------------------------------- 344 struct Frequency { 345 double ratio; 346 bool isFix; //if isFix no ratio but frequency 347 double freq; 348 }; 349 350 //--------------------------------------------------------- 351 // OscWave 352 //--------------------------------------------------------- 353 enum OscWave { 354 W1, //sine wave 355 W2, //sine� relative 356 W3, //half sine 357 W4, //half sine� relative 358 W5, 359 W6, 360 W7, 361 W8 362 }; 363 364 enum egShiftValue {VOF, V48, V24, V12}; 365 366 //--------------------------------------------------------- 367 // Eg 368 // Envelope 369 //--------------------------------------------------------- 370 struct Eg { 371 unsigned char ar; //0 to 31 speed attack 372 unsigned char d1r; //0 to 31 speed decay 373 unsigned char d1l; //0 to 15 level sustain 374 unsigned char d2r; //0 to 31 speed of sustain 375 unsigned char rr; //1 to 15 376 egShiftValue egShift; 377 }; 378 379 //--------------------------------------------------------- 380 // PitchEg 381 //--------------------------------------------------------- 382 struct PitchEg { 383 unsigned char pr1;//0 to 99 384 unsigned char pr2;//0 to 99 385 unsigned char pr3;//0 to 99 386 unsigned char pl1;//0 to 99 387 unsigned char pl2;//0 to 99 388 unsigned char pl3;//0 to 99 389 }; 390 391 //--------------------------------------------------------- 392 // Scaling 393 //--------------------------------------------------------- 394 struct Scaling { 395 unsigned char rate[NBROP];//0 to 3 396 unsigned char level[NBROP];//0 to 99 397 }; 398 399 //--------------------------------------------------------- 400 // Mode 401 //--------------------------------------------------------- 402 enum Mode { 403 POLY, 404 MONO 405 }; 406 407 //--------------------------------------------------------- 408 // Portamento 409 //--------------------------------------------------------- 410 enum Portamento { 411 FINGER, 412 FULL 413 }; 414 415 //--------------------------------------------------------- 416 // FootSw 417 //--------------------------------------------------------- 418 enum FootSw { 419 POR, 420 SUS 421 }; 422 //--------------------------------------------------------- 423 // Function 424 //--------------------------------------------------------- 425 struct Function { 426 int transpose; 427 Mode mode; 428 unsigned char pBendRange;//0 to 12 429 Portamento portamento; 430 unsigned char portamentoTime;//0 to 99 431 FootSw footSw; 432 unsigned char fcVolume;//0 to 99 433 unsigned char fcPitch;//0 to 99 434 unsigned char fcAmplitude;//0 to 99 435 unsigned char mwPitch;//0 to 99 436 unsigned char mwAmplitude;//0 to 99 437 unsigned char bcPitch;//0 to 99 438 unsigned char bcAmplitude;//0 to 99 439 signed char bcPitchBias;//-50 to 50 440 unsigned char bcEgBias;//0 to 99 441 unsigned char atPitch;//0 to 99 442 unsigned char atAmplitude;//0 to 99 443 signed char atPitchBias;//-50 to 50 444 unsigned char atEgBias;//0 to 99 445 signed char reverbRate;//O=off, 1 to 7 446 }; 447 448 //--------------------------------------------------------- 449 // Preset class 450 //--------------------------------------------------------- 451 452 class Preset { 453 public: 454 Subcategory* _subcategory; //subcategory parent 455 bool _isUsed; //false if the preset has never been used or modified, 456 //in this case the preset is not going to be 457 //save with the project 458 //Attributes 459 Algorithm algorithm; 460 unsigned char feedback; //0 to 7 461 Lfo lfo; 462 Sensitivity sensitivity; 463 Frequency frequency[NBROP]; 464 OscWave oscWave[NBROP]; 465 signed char detune[NBROP]; //-3 to 3 466 Eg eg[NBROP]; 467 PitchEg pitchEg; 468 unsigned char outLevel[NBROP]; //0 to 99 469 Scaling scaling; 470 Function function; 471 //int globalDetune; //-31 to 31 //now to the channel 472 std::string name; 473 //unsigned char modulation; //0 to 127 474 int prog; //0 to 127 475 //Methods 476 void printPreset(); 477 void initPreset(); 478 void readPreset(QDomNode qdn); 479 void writePreset(AL::Xml* xml, bool onlyUsed); 480 void linkSubcategory(Subcategory* sub); 481 void merge(Preset* p); //copy the data of p in the preset 482 void setIsUsed(bool b); //set flag _isUsed and transmit in the parents 483 void getHBankLBankProg(int* h, int* l, int* p); //return the hbank, lbank and prog of the preset 484 //Constructor destructor 485 Preset(); 486 Preset(Subcategory* sub); 487 Preset(Subcategory* sub, int prog); 488 ~Preset(); 489 }; 490 491 //--------------------------------------------------------------- 492 // Bank, organized by a tree of category, subcategory, preset 493 //--------------------------------------------------------------- 494 class Subcategory { 495 public: 496 Category* _category;//parent category 497 bool _isUsed; //false if the subcategory has never been used or modified, 498 //in this case the subcategory is not going to be 499 //save with the project 500 std::string _subcategoryName; 501 int _lbank; //0 to 127 502 std::vector<Preset*> _presetVector; 503 Preset* findPreset(int prog); 504 void readSubcategory(QDomNode subNode); 505 void writeSubcategory(AL::Xml* xml, bool onlyUsed); 506 void printSubcategory(); 507 void linkCategory(Category* cat); 508 void unlink(); 509 bool isFreeProg(int prog); 510 int firstFreeProg(); 511 void merge(Preset*); 512 //Constructor destructor 513 Subcategory(); 514 Subcategory(Category* cat); 515 Subcategory(const std::string name); 516 Subcategory(Category* cat, const std::string name, int lbank); 517 ~Subcategory(); 518 }; 519 520 class Category { 521 public: 522 Set* _set;//parent set 523 bool _isUsed; //false if the category has never been used or modified, 524 //in this case the category is not going to be 525 //save with the project 526 std::string _categoryName; 527 int _hbank; //0 to 127 528 std::vector<Subcategory*> _subcategoryVector; 529 Subcategory* findSubcategory(int lbank); 530 Preset* findPreset(int lbank, int prog); 531 void readCategory(QDomNode catNode); 532 void writeCategory(AL::Xml* xml, bool onlyUsed); 533 void printCategory(); 534 void linkSet(Set* s); 535 void unlink(); 536 bool isFreeLBank(int lbank); 537 int firstFreeLBank(); //return -1 if no free 538 void merge(Subcategory*); 539 //Constructor Destructor 540 Category(); 541 Category(Set* s); 542 Category(Set* s,const std::string name, int hbank); 543 ~Category(); 544 }; 545 546 class Set { 547 public: 548 std::string _setName; 549 std::vector<Category*> _categoryVector; 550 Preset* findPreset(int hbank, int lbank, int prog); 551 Subcategory* findSubcategory(int hbank, int lbank); 552 Category* findCategory(int hbank); 553 void readSet(QDomNode setNode); 554 void writeSet(AL::Xml* xml, bool onlyUsed); 555 void printSet(); 556 bool isFreeHBank(int hbank); 557 int firstFreeHBank(); 558 void merge(Category*); 559 //Constructor Destructor Set(const std::string name)560 Set(const std::string name){_setName=name;} ~Set()561 ~Set() { 562 while(!_categoryVector.empty()) delete(*_categoryVector.begin()); 563 } 564 }; 565 566 #endif /* __DEICSONZE_H */ 567