1 //=========================================================================== 2 // 3 // DeicsOnze an emulator of the YAMAHA DX11 synthesizer 4 // 5 // Version 0.5.5 6 // 7 // deicsonzegui.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 __DEICSONZEGUI_H 31 #define __DEICSONZEGUI_H 32 33 #include "awl/slider.h" 34 using Awl::Slider; 35 36 #include "deicsonze.h" 37 38 #include "deicsonzepreset.h" 39 #include "ui_deicsonzegui.h" 40 #include "libsynti/gui.h" 41 #include "awl/floatentry.h" 42 ///#include "awl/slider.h" 43 #include "awl/checkbox.h" 44 45 using Awl::FloatEntry; 46 ///using Awl::Slider; 47 using Awl::CheckBox; 48 49 //Envelope Gui constants 50 #define XOFFSET 2 51 #define YOFFSET 2 52 #define PENWIDTH 2 53 #define DOTWIDTH 3 54 #define DRAGWIDTH 6 //size of the mousetracking threshold 55 //pitch envelope constants 56 #define WALLWIDTH 6 57 #define PR1WIDTH (width()/3-9) 58 #define PR2WIDTH PR1WIDTH 59 #define PR3WIDTH PR1WIDTH 60 #define PL1HEIGHT (height()-4) 61 #define PL2HEIGHT PL1HEIGHT 62 #define PL3HEIGHT PL1HEIGHT 63 #define MAXPWIDTH PR1WIDTH+WALLWIDTH+PR2WIDTH+WALLWIDTH+PR3WIDTH+WALLWIDTH+PR1WIDTH 64 #define MAXPHEIGHT PL1HEIGHT 65 #define STEPVALUE 10 66 //amplitude envelope constants 67 #define ARWIDTH (width()/4-1) 68 #define D1RWIDTH ARWIDTH 69 #define D1LHEIGHT (height()-2) 70 #define D2RWIDTH ARWIDTH 71 #define RRWIDTH ARWIDTH 72 #define MAXWIDTH ARWIDTH+D1RWIDTH+D1RWIDTH+RRWIDTH 73 #define MAXHEIGHT D1LHEIGHT 74 75 //COLOR 76 #define TCOLOR QColor(0, 0, 0) //text color 77 #define BCOLOR QColor(210, 180, 90) //background color 78 #define ETCOLOR QColor(0, 150, 0) //edit text color 79 #define EBCOLOR QColor(255, 255, 30) //edit background color 80 81 class DeicsOnze; 82 class QFramePitchEnvelope; 83 class QFrameEnvelope; 84 85 class QTreeCategory:public QTreeWidgetItem { 86 public: 87 Category* _category; QTreeCategory(QTreeWidget * p,QString shbank,QString l,Category * c)88 QTreeCategory(QTreeWidget* p, QString shbank, QString l, Category* c) 89 :QTreeWidgetItem(p) { 90 setText(0, shbank); 91 setText(1, l); 92 _category=c; 93 }; 94 }; 95 96 class QTreeSubcategory:public QTreeWidgetItem { 97 public: 98 Subcategory* _subcategory; QTreeSubcategory(QTreeWidget * p,QString slbank,QString l,Subcategory * s)99 QTreeSubcategory(QTreeWidget* p, QString slbank, 100 QString l, Subcategory* s) 101 :QTreeWidgetItem(p) { 102 setText(0, slbank); 103 setText(1, l); 104 _subcategory=s; 105 }; 106 }; 107 108 class QTreePreset:public QTreeWidgetItem { 109 public: 110 Preset* _preset; QTreePreset(QTreeWidget * pa,QString sprog,QString l,Preset * p)111 QTreePreset(QTreeWidget* pa, QString sprog, QString l, Preset* p) 112 :QTreeWidgetItem(pa) { 113 setText(0, sprog); 114 setText(1, l); 115 _preset=p; 116 }; 117 }; 118 119 //--------------------------------------------------------- 120 // DeicsOnzeGui 121 //--------------------------------------------------------- 122 class DeicsOnzeGui : public QDialog, public Ui::DeicsOnzeGuiBase, public MessGui { 123 Q_OBJECT 124 125 bool _enabledPreset; 126 127 QFramePitchEnvelope* pitchEnvelopeGraph; 128 QFrameEnvelope* envelopeGraph[NBROP]; 129 130 QWidget* _chorusSuperWidget; 131 QWidget* _reverbSuperWidget; 132 std::vector<Slider*> _chorusSliderVector; 133 std::vector<FloatEntry*> _chorusFloatEntryVector; 134 std::vector<CheckBox*> _chorusCheckBoxVector; 135 std::vector<Slider*> _reverbSliderVector; 136 std::vector<FloatEntry*> _reverbFloatEntryVector; 137 std::vector<CheckBox*> _reverbCheckBoxVector; 138 139 140 QString lastDir; 141 private slots: 142 void readMessage(); 143 void setEnabledChannel(bool); 144 void setChangeChannel(int); 145 void setPanic(); 146 void setResCtrl(); 147 void setNbrVoices(int); 148 void setSaveOnlyUsed(bool); 149 void setSaveOnlyUsedComp(bool); 150 void setSaveConfig(bool); 151 // void setMidiInCh(int); //to change 152 void setQuality(const QString&); 153 void setFilter(bool); 154 void setFontSize(int); 155 void saveConfiguration(); 156 void saveDefaultConfiguration(); 157 void loadConfiguration(); 158 void loadConfiguration(QString s); 159 //load init set 160 void setIsInitSet(bool); 161 void setInitSetPath(const QString&); 162 void setBrowseInitSetPath(); 163 //load init set 164 void setIsBackgroundPix(bool); 165 void setBackgroundPixPath(const QString&); 166 void setBrowseBackgroundPixPath(); 167 //FX 168 void setChorusActiv(bool a); 169 void setChannelChorus(int c); 170 void setChorusReturn(int al); 171 void setSelectChorusPlugin(); 172 void setReverbCheckBox(double v, int i); 173 void setChorusCheckBox(double v, int i); 174 void setReverbActiv(bool a); 175 void setChannelReverb(int r); 176 void setReverbReturn(int val); 177 void setSelectReverbPlugin(); 178 void setReverbFloatEntry(double v, int i); 179 void setReverbSlider(double v, int i); 180 void setChorusFloatEntry(double v, int i); 181 void setChorusSlider(double v, int i); 182 //quick edit 183 void setChannelVolKnob(double val); 184 void setChannelPan(double val); 185 void setBrightnessKnob(double val); 186 void setModulationKnob(double val); 187 void setDetuneKnob(double val); 188 void setAttackKnob(double val); 189 void setReleaseKnob(double val); 190 //Color 191 void setRedColor(int); 192 void setGreenColor(int); 193 void setBlueColor(int); 194 void setRGBSliders(QListWidgetItem*); 195 void setTextColor(const QColor &); 196 void setBackgroundColor(const QColor &); 197 void setEditTextColor(const QColor &); 198 void setEditBackgroundColor(const QColor &); 199 //New Delete Load Save 200 void deleteSetDialog(); 201 void loadSetDialog(); 202 void saveSetDialog(); 203 void deleteCategoryDialog(); 204 void newCategoryDialog(); 205 void loadCategoryDialog(); 206 void saveCategoryDialog(); 207 void deleteSubcategoryDialog(); 208 void newSubcategoryDialog(); 209 void loadSubcategoryDialog(); 210 void saveSubcategoryDialog(); 211 void newPresetDialog(); 212 void loadPresetDialog(); 213 void deletePresetDialog(); 214 void savePresetDialog(); 215 //popupMenu 216 void categoryPopupMenu(const QPoint&); 217 void subcategoryPopupMenu(const QPoint&); 218 void presetPopupMenu(const QPoint&); 219 //Preset and bank 220 void setPresetName(const QString&); 221 void setSubcategoryName(const QString&); 222 void setCategoryName(const QString&); 223 void setHBank(int); 224 void setLBank(int); 225 void setProg(int); 226 //Global 227 void setMasterVolKnob(double); 228 void setMasterVol(int); 229 void setFeedback(int); 230 void setLfoWave(int); 231 void setLfoSpeed(int); 232 void setLfoDelay(int); 233 void setLfoPModDepth(int); 234 void setLfoPitchSens(int); 235 void setLfoAModDepth(int); 236 void setLfoAmpSens(int); 237 void setTranspose(int); 238 void setChannelDetune(int); 239 void setAlgorithm(int); 240 void setPitchBendRange(int); 241 //Pitch Envelope 242 void setPL1(int); 243 void setPL2(int); 244 void setPL3(int); 245 void setPR1(int); 246 void setPR2(int); 247 void setPR3(int); 248 //Function 249 void setFcVolume(int); 250 void setFcPitch(int); 251 void setFcAmplitude(int); 252 void setMwPitch(int); 253 void setMwAmplitude(int); 254 void setBcPitch(int); 255 void setBcAmplitude(int); 256 void setBcPitchBias(int); 257 void setBcEgBias(int); 258 void setAtPitch(int); 259 void setAtAmplitude(int); 260 void setAtPitchBias(int); 261 void setAtEgBias(int); 262 void setReverbRate(int); 263 void setPolyMode(int); 264 void setPortFingerFull(int); 265 void setPortaTime(int); 266 //envelope 267 void setAR1(int val); 268 void setD1R1(int val); 269 void setD1L1(int val); 270 void setD2R1(int val); 271 void setRR1(int val); 272 void setAR2(int val); 273 void setD1R2(int val); 274 void setD1L2(int val); 275 void setD2R2(int val); 276 void setRR2(int val); 277 void setAR3(int val); 278 void setD1R3(int val); 279 void setD1L3(int val); 280 void setD2R3(int val); 281 void setRR3(int val); 282 void setAR4(int val); 283 void setD1R4(int val); 284 void setD1L4(int val); 285 void setD2R4(int val); 286 void setRR4(int val); 287 //scaling 288 void setLS1(int val); 289 void setRS1(int val); 290 void setLS2(int val); 291 void setRS2(int val); 292 void setLS3(int val); 293 void setRS3(int val); 294 void setLS4(int val); 295 void setRS4(int val); 296 //vol 297 void setVol1(int val); 298 void setVol2(int val); 299 void setVol3(int val); 300 void setVol4(int val); 301 //Ratio and Frequency 302 void setCoarseRatio1(int val); 303 void setFineRatio1(int val); 304 void setFreq1(int val); 305 void setFix1(bool f); 306 void setCoarseRatio2(int val); 307 void setFineRatio2(int val); 308 void setFreq2(int val); 309 void setFix2(bool f); 310 void setCoarseRatio3(int val); 311 void setFineRatio3(int val); 312 void setFreq3(int val); 313 void setFix3(bool f); 314 void setCoarseRatio4(int val); 315 void setFineRatio4(int val); 316 void setFreq4(int val); 317 void setFix4(bool f); 318 //Sensitivity 319 void setAME1(bool val); 320 void setEBS1(int val); 321 void setKVS1(int val); 322 void setAME2(bool val); 323 void setEBS2(int val); 324 void setKVS2(int val); 325 void setAME3(bool val); 326 void setEBS3(int val); 327 void setKVS3(int val); 328 void setAME4(bool val); 329 void setEBS4(int val); 330 void setKVS4(int val); 331 //detune 332 void setDET1(int val); 333 void setDET2(int val); 334 void setDET3(int val); 335 void setDET4(int val); 336 //WaveForm 337 void setWaveForm1(int); 338 void setWaveForm2(int); 339 void setWaveForm3(int); 340 void setWaveForm4(int); 341 //Delay 342 void setActivDelay(bool); 343 void setDelayReturn(int); 344 void setChannelDelay(int); 345 //void setDelayTime(int); 346 void setDelayBPM(double); 347 void setDelayBeatRatio(double); 348 //void setDelayFeedback(int); 349 void setDelayFeedback(double); 350 //void setDelayPanLFOFreq(int); 351 void setDelayPanLFOFreq(double); 352 //void setDelayPanLFODepth(int); 353 void setDelayPanLFODepth(double); 354 //category subcategory preset 355 void setSet(void); //display the set, that is the category list 356 void setCategory(Category*); 357 void setCategory(QTreeWidgetItem*); 358 void setSubcategory(Subcategory*); 359 void setSubcategory(QTreeWidgetItem*); 360 void setPreset(QTreeWidgetItem*); 361 public: 362 virtual void processEvent(const MusECore::MidiPlayEvent&); 363 void updateSelectPreset(int hbank, int lbank, int prog); 364 //update the gui 365 void setEnabledPreset(bool b); 366 void updateChannelCheckBox(bool b); 367 void updateEnabledChannel(bool e);//put enabled the display concerning channel and preset 368 void updateChannelEnable(bool e);//update channel enable 369 void updateMasterVolume(int val); 370 void updateNbrVoices(int val); 371 //void updateMidiInCh(int val); //to change 372 void updateQuality(int val); 373 void updateFilter(bool f); 374 void updateFontSize(int fs); 375 void applyFontSize(int fs); 376 void updateSaveOnlyUsed(bool); 377 void updateSaveConfig(bool); 378 //FX 379 void updateChorusActiv(bool a); 380 void updateChannelChorus(int c); 381 void updateChorusReturn(int r); 382 void updateReverbActiv(bool a); 383 void updateChannelReverb(int r); 384 void updateReverbReturn(int r); 385 void updateLadspaReverbLineEdit(QString s); 386 void updateLadspaChorusLineEdit(QString s); 387 void updateDelayActiv(bool a); 388 void updateChannelDelay(int r); 389 void updateDelayReturn(int r); 390 void updateDelayPanLFOFreq(float plf); 391 void updateDelayBPM(float dt); 392 void updateDelayBeatRatio(float dt); 393 void updateDelayFeedback(float df); 394 void updateDelayPanLFODepth(float dpd); 395 void addPluginCheckBox(int index, QString text, bool toggled, 396 QWidget* parent, QGridLayout* grid, bool isReverb); 397 void addPluginIntSlider(int index, QString text, double min, double max, 398 double val, QWidget* parent, QGridLayout* grid, 399 bool isReverb); 400 void addPluginSlider(int index, QString text, bool isLog, double min, 401 double max, double val, QWidget* parent, 402 QGridLayout* grid, bool isReverb); 403 void buildGuiReverb(); 404 void buildGuiChorus(); 405 void updateReverbSlider(double v, int i); 406 void updateReverbFloatEntry(double v, int i); 407 void updateChorusSlider(double v, int i); 408 void updateChorusFloatEntry(double v, int i); 409 //update load init set 410 void updateInitSetCheckBox(bool); 411 void updateInitSetPath(QString); 412 //update background pix 413 void updateBackgroundPixCheckBox(bool); 414 void updateBackgroundPixPath(QString); 415 void applyBackgroundPix(); 416 //update quick edit 417 void updateChannelPan(int val); 418 void updateBrightness(int val); 419 void updateModulation(int val); 420 void updateAttack(int val); 421 void updateRelease(int val); 422 void updateQuickEdit(); 423 //update pitch envelope 424 void updatePL1(int val); 425 void updatePL2(int val); 426 void updatePL3(int val); 427 void updatePR1(int val); 428 void updatePR2(int val); 429 void updatePR3(int val); 430 //update function 431 void updateFcVolume(int val); 432 void updateFcPitch(int val); 433 void updateFcAmplitude(int val); 434 void updateMwPitch(int val); 435 void updateMwAmplitude(int val); 436 void updateBcPitch(int val); 437 void updateBcAmplitude(int val); 438 void updateBcPitchBias(int val); 439 void updateBcEgBias(int val); 440 void updateAtPitch(int val); 441 void updateAtAmplitude(int val); 442 void updateAtPitchBias(int val); 443 void updateAtEgBias(int val); 444 //void updateReverbRate(int val); 445 //update envelope 446 void updateAR(int op, int val); 447 void updateD1R(int op, int val); 448 void updateD2R(int op, int val); 449 void updateRR(int op, int val); 450 void updateD1L(int op, int val); 451 //update scale 452 void updateLS(int op, int val); 453 void updateRS(int op, int val); 454 void updateEBS(int op, int val); 455 void updateAME(int op, bool val); 456 void updateKVS(int op, int val); 457 void updateOUT(int op, int val); 458 void updateRATIO(int op, int val); 459 void updateDET(int op, int val); 460 //update global 461 void updateALG(int val); 462 void updateFEEDBACK(int val); 463 void updateSPEED(int val); 464 void updateDELAY(int val); 465 void updatePMODDEPTH(int val); 466 void updateAMODDEPTH(int val); 467 void updateSYNC(bool val); 468 void updateWAVE(int val); 469 void updatePMODSENS(int val); 470 void updateAMS(int val); 471 void updateTRANSPOSE(int val); 472 void updatePOLYMODE(int val); 473 void updatePBENDRANGE(int val); 474 void updatePORTAMODE(int val); 475 void updatePORTATIME(int val); 476 void updateFIX(int op, bool val); 477 void updateFIXRANGE(int op, int val); 478 void updateOSW(int op, int val); 479 void updateSHFT(int op, int val); 480 void updateChannelDetune(int val); 481 void updateChannelDetuneKnob(int val); 482 //void updateChannelDetuneSlider(int val); 483 void updateChannelVolume(int val); 484 void updateCategoryName(QString cn, bool enable); 485 void updateSubcategoryName(QString sn, bool enable); 486 void updatePresetName(QString pn, bool enable); 487 void updatePresetName(QString pn); 488 void updateHBank(int hbank, bool enable); 489 void updateLBank(int lbank, bool enable); 490 void updateProg(int prog, bool enable); 491 void updatePreset(Preset* p); 492 void updatePreset(void); //update gui following the current preset 493 //void updateCurrentChannel(); //update gui channel attributes 494 QString num3Digits(int); 495 DeicsOnzeGui(DeicsOnze*); 496 497 int _currentChannel; 498 499 QColor* tColor; //text color 500 QColor* bColor; //background color 501 QColor* etColor;//edit text color 502 QColor* ebColor;//edit background color 503 QColor* curColor;//current color 504 505 DeicsOnze* _deicsOnze; 506 }; 507 508 class QFramePitchEnvelope:private QFrame { 509 QPoint startlinkP1, //first point 510 P1linkP2, //point linking P1 to P2 511 P2linkP3, //point linking P2 to P3 512 P3linkEnd; //point linking P3 to End 513 bool isStartlinkP1Edit; 514 bool isP1linkP2Edit; 515 bool isP2linkP3Edit; 516 bool isP3linkEndEdit; 517 public: 518 DeicsOnzeGui* _deicsOnzeGui; QFramePitchEnvelope(QWidget * parent,DeicsOnzeGui * dog)519 QFramePitchEnvelope(QWidget* parent, DeicsOnzeGui* dog):QFrame(parent){ 520 _deicsOnzeGui = dog; 521 isStartlinkP1Edit=false; 522 isP1linkP2Edit=false; 523 isP2linkP3Edit=false; 524 isP3linkEndEdit=false; 525 }; 526 void env2Points(int pl1, int pl2, int pl3, int pr1, int pr2, int pr3); updateEnv(void)527 void updateEnv(void) {update();}; 528 protected: 529 virtual void paintEvent(QPaintEvent* e); 530 virtual void mouseMoveEvent(QMouseEvent* e); 531 virtual void mousePressEvent(QMouseEvent * e); 532 virtual void mouseReleaseEvent(QMouseEvent * e); 533 }; 534 535 class QFrameEnvelope:private QFrame { 536 unsigned char op; //operator number, between 0 and 3 537 QPoint startlinkAR, //first point 538 ARlinkD1, //point linking AR to D1 539 D1linkD2, //point linking D1 to D2 540 D2linkRR, //point linking D2 to RR 541 RRlinkEnd; //last point 542 bool isARlinkD1Edit; 543 bool isD1linkD2Edit; 544 bool isD2linkRREdit; 545 bool isRRlinkEndEdit; 546 public: 547 DeicsOnzeGui* _deicsOnzeGui; QFrameEnvelope(QWidget * parent,DeicsOnzeGui * dog,unsigned char k)548 QFrameEnvelope(QWidget* parent, DeicsOnzeGui* dog, unsigned char k):QFrame(parent){ 549 _deicsOnzeGui = dog; 550 isARlinkD1Edit=false; 551 isD1linkD2Edit=false; 552 isD2linkRREdit=false; 553 isRRlinkEndEdit=false; 554 op = k; 555 //setGeometry(XOFFSET, YOFFSET, XOFFSET+MAXWIDTH, MAXHEIGHT); 556 //setMouseTracking(true); 557 }; 558 void env2Points(int ar, int d1r, int d1l, int d2r, int rr); updateEnv(void)559 void updateEnv(void) {update();}; 560 protected: 561 void paintEvent(QPaintEvent* e); 562 void mouseMoveEvent(QMouseEvent* e); 563 void mousePressEvent(QMouseEvent * e); 564 void mouseReleaseEvent(QMouseEvent * e); 565 }; 566 567 #endif /* __DEICSONZEGUI_H */ 568