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
|
//===========================================================================
//
// 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.
//===========================================================================
#include "deicsonzeplugin.h"
#include "muse/plugin.h"
//#include "plugingui.h"
#include "muse/ctrl.h"
#include "muse/fastlog.h"
#include "muse/midi.h"
//Added by qt3to4:
#include <Q3GridLayout>
#include <QLabel>
//#include "awl/floatentry.h"
//#include "awl/slider.h"
//#include "awl/checkbox.h"
//using Awl::FloatEntry;
//using Awl::Slider;
//using Awl::CheckBox;
class PluginDialog;
void DeicsOnze2::initPluginReverb(Plugin* pluginReverb) {
//init plugin
if(_pluginIReverb) delete(_pluginIReverb);
_pluginIReverb = new PluginI(NULL);
_pluginIReverb->initPluginInstance(pluginReverb, 2);
for(int i = 0; i < pluginReverb->parameter(); i++) {
Ctrl* c = new Ctrl();
c->setCurVal((float)pluginReverb->defaultValue(i));
_pluginIReverb->setControllerList(c);
//setReverbParam(i, pluginReverb->defaultValue(i));
}
//send build gui to the gui
char data;
data = SYSEX_BUILDGUIREVERB;
MidiEvent evSysex(0,ME_SYSEX,(const unsigned char*)&data, 1);
_gui->writeEvent(evSysex);
}
void DeicsOnze2::initPluginChorus(Plugin* pluginChorus) {
if(_pluginIChorus) delete(_pluginIChorus);
_pluginIChorus = new PluginI(NULL);
_pluginIChorus->initPluginInstance(pluginChorus, 2);
for(int i = 0; i < pluginChorus->parameter(); i++) {
Ctrl* c = new Ctrl();
c->setCurVal((float)pluginChorus->defaultValue(i));
_pluginIChorus->setControllerList(c);
//setChorusParam(i, pluginChorus->defaultValue(i));
}
//send build gui to the gui
char data;
data = SYSEX_BUILDGUICHORUS;
MidiEvent evSysex(0,ME_SYSEX,(const unsigned char*)&data, 1);
_gui->writeEvent(evSysex);
}
void DeicsOnze2::initPluginDelay(Plugin* pluginDelay) {
if(_pluginIDelay) delete(_pluginIDelay);
_pluginIDelay = new PluginI(NULL);
_pluginIDelay->initPluginInstance(pluginDelay, 2);
for(int i = 0; i < pluginDelay->parameter(); i++) {
Ctrl* c = new Ctrl();
c->setCurVal((float)pluginDelay->defaultValue(i));
_pluginIDelay->setControllerList(c);
//setChorusParam(i, pluginDelay->defaultValue(i));
}
setDelayDryWet(1);
float f;
char dataDelayBPM[sizeof(float)+1];
dataDelayBPM[0] = SYSEX_DELAYBPM;
f = getDelayBPM();
memcpy(&dataDelayBPM[1], &f, sizeof(float));
MidiEvent evSysexDelayBPM(0,ME_SYSEX,
(const unsigned char*)dataDelayBPM,
sizeof(float)+1);
_gui->writeEvent(evSysexDelayBPM);
char dataDelayBeatRatio[sizeof(float)+1];
dataDelayBeatRatio[0] = SYSEX_DELAYBEATRATIO;
f = getDelayBeatRatio();
memcpy(&dataDelayBeatRatio[1], &f, sizeof(float));
MidiEvent evSysexDelayBeatRatio(0,ME_SYSEX,
(const unsigned char*)dataDelayBeatRatio,
sizeof(float)+1);
_gui->writeEvent(evSysexDelayBeatRatio);
char dataDelayFeedback[sizeof(float)+1];
dataDelayFeedback[0] = SYSEX_DELAYFEEDBACK;
f = getDelayFeedback();
memcpy(&dataDelayFeedback[1], &f, sizeof(float));
MidiEvent evSysexDelayFeedback(0,ME_SYSEX,
(const unsigned char*)dataDelayFeedback,
sizeof(float)+1);
_gui->writeEvent(evSysexDelayFeedback);
char dataDelayLFOFreq[sizeof(float)+1];
dataDelayLFOFreq[0] = SYSEX_DELAYLFOFREQ;
f = getDelayLFOFreq();
memcpy(&dataDelayLFOFreq[1], &f, sizeof(float));
MidiEvent evSysexDelayLFOFreq(0,ME_SYSEX,
(const unsigned char*)dataDelayLFOFreq,
sizeof(float)+1);
_gui->writeEvent(evSysexDelayLFOFreq);
char dataDelayLFODepth[sizeof(float)+1];
dataDelayLFODepth[0] = SYSEX_DELAYLFODEPTH;
f = getDelayLFODepth();
memcpy(&dataDelayLFODepth, &f, sizeof(float)+1);
MidiEvent evSysexDelayLFODepth(0,ME_SYSEX,
(const unsigned char*)dataDelayLFODepth,
sizeof(float)+1);
_gui->writeEvent(evSysexDelayLFODepth);
}
void DeicsOnze2::setReverbParam(int index, double val) {
if(_pluginIReverb) _pluginIReverb->controller(index)->setCurVal((float)val);
else printf("Warning : no DeicsOnze2 reverb loaded\n");
}
void DeicsOnze2::setChorusParam(int index, double val) {
if(_pluginIChorus) _pluginIChorus->controller(index)->setCurVal((float)val);
else printf("Warning : no DeicsOnze2 chorus loaded\n");
}
double DeicsOnze2::getReverbParam(int index) {
if(_pluginIReverb) return _pluginIReverb->controller(index)->curVal().f;
else {
return 0.0;
printf("Warning : no DeicsOnze2 reverb loaded\n");
}
}
double DeicsOnze2::getChorusParam(int index) {
if(_pluginIChorus) return _pluginIChorus->controller(index)->curVal().f;
else {
return 0.0;
printf("Warning : no DeicsOnze2 chorus loaded\n");
}
}
void DeicsOnze2Gui::addPluginCheckBox(int index, QString text, bool toggled,
QWidget* parent, Q3GridLayout* grid,
bool isReverb) {
CheckBox* cb = new CheckBox(parent);
cb->setId(index);
cb->setText(text);
cb->setChecked(toggled);
grid->addWidget(cb, index, 0);
//push on vectors
if(isReverb) {
_reverbSliderVector.push_back(NULL);
_reverbFloatEntryVector.push_back(NULL);
_reverbCheckBoxVector.push_back(cb);
}
else {
_chorusSliderVector.push_back(NULL);
_chorusFloatEntryVector.push_back(NULL);
_chorusCheckBoxVector.push_back(cb);
}
//connect slots
if(isReverb) {
connect(cb, SIGNAL(valueChanged(double, int)),
this, SLOT(setReverbCheckBox(double, int)));
}
else {
connect(cb, SIGNAL(valueChanged(double, int)),
this, SLOT(setChorusCheckBox(double, int)));
}
}
void DeicsOnze2Gui::addPluginIntSlider(int index, QString text, double min,
double max, double val, QWidget* parent,
Q3GridLayout* grid, bool isReverb) {
addPluginSlider(index, text, false, min, max, val, parent, grid, isReverb);
}
void DeicsOnze2Gui::addPluginSlider(int index, QString text, bool isLog,
double min, double max, double val,
QWidget* parent, Q3GridLayout* grid,
bool isReverb) {
QLabel* l = new QLabel(text, parent);
grid->addWidget(l, index, 0);
FloatEntry* f = new FloatEntry(parent);
f->setValue(val);
f->setMinValue(min);
f->setMaxValue(max);
f->setMaximumWidth(72);
grid->addWidget(f, index, 1);
Slider* s = new Slider(parent);
s->setId(index);
s->setLog(isLog);
s->setLogRange(min, max);
s->setValue(val);
s->setOrientation(Qt::Horizontal);
//s->setFixedHeight(h);
s->setLineStep((min-max)/100.0);
s->setPageStep((min-max)/10.0);
grid->addWidget(s, index, 2);
//push on vectors
if(isReverb) {
_reverbSliderVector.push_back(s);
_reverbFloatEntryVector.push_back(f);
_reverbCheckBoxVector.push_back(NULL);
}
else {
_chorusSliderVector.push_back(s);
_chorusFloatEntryVector.push_back(f);
_chorusCheckBoxVector.push_back(NULL);
}
//connect slots
if(isReverb) {
connect(f, SIGNAL(valueChanged(double, int)),
this, SLOT(setReverbFloatEntry(double, int)));
connect(s, SIGNAL(valueChanged(double, int)),
this, SLOT(setReverbSlider(double, int)));
}
else {
connect(f, SIGNAL(valueChanged(double, int)),
this, SLOT(setChorusFloatEntry(double, int)));
connect(s, SIGNAL(valueChanged(double, int)),
this, SLOT(setChorusSlider(double, int)));
}
}
void DeicsOnze2Gui::buildGuiReverb() {
PluginI* plugI = _deicsOnze->_pluginIReverb;
QString name = plugI->name();
name.resize(name.size()-2);
updateLadspaReverbLineEdit(name);
//build super layout
if(parametersReverbGroupBox->layout())
delete(parametersReverbGroupBox->layout());
Q3GridLayout* superLayout = new Q3GridLayout(parametersReverbGroupBox);
parametersReverbGroupBox->setLayout(superLayout);
//build super widget
if(_reverbSuperWidget) delete(_reverbSuperWidget);
_reverbSuperWidget = new QWidget(parametersReverbGroupBox);
superLayout->addWidget(_reverbSuperWidget);
//build grid
Q3GridLayout* grid = new Q3GridLayout(_reverbSuperWidget);
_reverbSuperWidget->setLayout(grid);
grid->setSpacing(0);
//init vectors
if(!_reverbSliderVector.empty()) _reverbSliderVector.clear();
if(!_reverbFloatEntryVector.empty()) _reverbFloatEntryVector.clear();
if(!_reverbCheckBoxVector.empty()) _reverbCheckBoxVector.clear();
//build sliders
for(int i = 0; i < plugI->plugin()->parameter(); i++) {
double min, max, val;
plugI->range(i, &min, &max);
val = _deicsOnze->getReverbParam(i);
if(plugI->isBool(i))
addPluginCheckBox(i, plugI->getParameterName(i), val > 0.0,
_reverbSuperWidget, grid, true);
else if(plugI->isInt(i)) {
addPluginIntSlider(i, plugI->getParameterName(i), rint(min), rint(max),
rint(val), _reverbSuperWidget, grid, true);
}
else {
addPluginSlider(i, plugI->getParameterName(i), plugI->isLog(i),
min, max, val, _reverbSuperWidget, grid, true);
}
}
//update colors of the new sliders (and the whole gui actually)
setEditTextColor(reinterpret_cast<const QColor &>(*etColor));
setEditBackgroundColor(reinterpret_cast<const QColor &>(*ebColor));
}
void DeicsOnze2Gui::buildGuiChorus() {
PluginI* plugI = _deicsOnze->_pluginIChorus;
QString name = plugI->name();
name.resize(name.size()-2);
updateLadspaChorusLineEdit(name);
//build super layout
if(parametersChorusGroupBox->layout())
delete(parametersChorusGroupBox->layout());
Q3GridLayout* superLayout = new Q3GridLayout(parametersChorusGroupBox);
parametersChorusGroupBox->setLayout(superLayout);
//build super widget
if(_chorusSuperWidget) delete(_chorusSuperWidget);
_chorusSuperWidget = new QWidget(parametersChorusGroupBox);
superLayout->addWidget(_chorusSuperWidget);
//build grid
Q3GridLayout* grid = new Q3GridLayout(_chorusSuperWidget);
_chorusSuperWidget->setLayout(grid);
grid->setSpacing(2);
//init vectors
if(!_chorusSliderVector.empty()) _chorusSliderVector.clear();
if(!_chorusFloatEntryVector.empty()) _chorusFloatEntryVector.clear();
if(!_chorusCheckBoxVector.empty()) _chorusCheckBoxVector.clear();
//build sliders
for(int i = 0; i < plugI->plugin()->parameter(); i++) {
double min, max, val;
plugI->range(i, &min, &max);
val = _deicsOnze->getChorusParam(i);
if(plugI->isBool(i))
addPluginCheckBox(i, plugI->getParameterName(i), val > 0.0,
_chorusSuperWidget, grid, false);
else if(plugI->isInt(i)) {
addPluginIntSlider(i, plugI->getParameterName(i), rint(min), rint(max),
rint(val), _chorusSuperWidget, grid, false);
}
else {
addPluginSlider(i, plugI->getParameterName(i), plugI->isLog(i),
min, max, val, _chorusSuperWidget, grid, false);
}
}
//update colors of the new sliders (and the whole gui actually)
setEditTextColor(reinterpret_cast<const QColor &>(*etColor));
setEditBackgroundColor(reinterpret_cast<const QColor &>(*ebColor));
}
//setReverbCheckBox is used, by the way, to send the value
//of the parameter because it sends a double and does not
//change any thing
void DeicsOnze2Gui::setReverbCheckBox(double v, int i) {
float f = (float)v;
unsigned char* message = new unsigned char[2+sizeof(float)];
message[0]=SYSEX_REVERBPARAM;
if(i<256) {
message[1]=(unsigned char)i;
memcpy(&message[2], &f, sizeof(float));
sendSysex(message, 2+sizeof(float));
}
else printf("setReverbCheckBox Error : cannot send controller upper than 225\n");
}
//setChorusCheckBox is used, by the way, to send the value
//of the parameter because it sends a double and does not
//change any thing
void DeicsOnze2Gui::setChorusCheckBox(double v, int i) {
float f = (float)v;
unsigned char* message = new unsigned char[2+sizeof(float)];
message[0]=SYSEX_CHORUSPARAM;
if(i<256) {
message[1]=(unsigned char)i;
memcpy(&message[2], &f, sizeof(float));
sendSysex(message, 2+sizeof(float));
}
else printf("setChorusCheckBox Error : cannot send controller upper than 225\n");
}
void DeicsOnze2Gui::setReverbFloatEntry(double v, int i) {
if(_deicsOnze->_pluginIReverb) {
if(_deicsOnze->_pluginIReverb->isInt(i)) v = rint(v);
updateReverbFloatEntry(v, i);
updateReverbSlider(v, i);
setReverbCheckBox(v, i); //because this send the SYSEX
}
else printf("Warning : no DeicsOnze2 reverb loaded\n");
}
void DeicsOnze2Gui::setReverbSlider(double v, int i) {
if(_deicsOnze->_pluginIReverb) {
if(_deicsOnze->_pluginIReverb->isInt(i)) v = rint(v);
updateReverbFloatEntry(v, i);
updateReverbSlider(v, i);
setReverbCheckBox(v, i); //because this send the SYSEX
}
else printf("Warning : no DeicsOnze2 reverb loaded\n");
}
void DeicsOnze2Gui::setChorusFloatEntry(double v, int i) {
if(_deicsOnze->_pluginIReverb) {
if(_deicsOnze->_pluginIChorus->isInt(i)) v = rint(v);
updateChorusFloatEntry(v, i);
updateChorusSlider(v, i);
setChorusCheckBox(v, i); //because this send the SYSEX
}
else printf("Warning : no DeicsOnze2 chorus loaded\n");
}
void DeicsOnze2Gui::setChorusSlider(double v, int i) {
if(_deicsOnze->_pluginIReverb) {
if(_deicsOnze->_pluginIChorus->isInt(i)) v = rint(v);
updateChorusSlider(v, i);
updateChorusFloatEntry(v, i);
setChorusCheckBox(v, i); //because this send the SYSEX
}
else printf("Warning : no DeicsOnze2 chorus loaded\n");
}
//updates
void DeicsOnze2Gui::updateReverbSlider(double v, int i) {
if(i < (int)_reverbSliderVector.size() && _reverbSliderVector[i]) {
_reverbSliderVector[i]->blockSignals(true);
_reverbSliderVector[i]->setValue(v);
_reverbSliderVector[i]->blockSignals(false);
}
}
void DeicsOnze2Gui::updateReverbFloatEntry(double v, int i) {
if(i < (int)_reverbFloatEntryVector.size() && _reverbFloatEntryVector[i]) {
_reverbFloatEntryVector[i]->blockSignals(true);
_reverbFloatEntryVector[i]->setValue(v);
_reverbFloatEntryVector[i]->blockSignals(false);
}
}
void DeicsOnze2Gui::updateChorusSlider(double v, int i) {
if(i < (int)_reverbSliderVector.size() && _reverbSliderVector[i]) {
_chorusSliderVector[i]->blockSignals(true);
_chorusSliderVector[i]->setValue(v);
_chorusSliderVector[i]->blockSignals(false);
}
}
void DeicsOnze2Gui::updateChorusFloatEntry(double v, int i) {
if(i < (int)_chorusFloatEntryVector.size() && _chorusFloatEntryVector[i]) {
_chorusFloatEntryVector[i]->blockSignals(true);
_chorusFloatEntryVector[i]->setValue(v);
_chorusFloatEntryVector[i]->blockSignals(false);
}
}
//-------------------------------------------------------------
// set Delay
//-------------------------------------------------------------
void DeicsOnze2::setDelayBPM(float val) {
if(_pluginIDelay) _pluginIDelay->controller(0)->setCurVal(val);
else printf("Warning : no DeicsOnze2 delay loaded\n");
}
void DeicsOnze2::setDelayBeatRatio(float val) {
if(_pluginIDelay) _pluginIDelay->controller(1)->setCurVal(val);
else printf("Warning : no DeicsOnze2 delay loaded\n");
}
float DeicsOnze2::getDelayBPM() {
if(_pluginIDelay) return _pluginIDelay->controller(0)->curVal().f;
else {
printf("Warning : no DeicsOnze2 delay loaded\n");
return 0.0;
}
}
float DeicsOnze2::getDelayBeatRatio() {
if(_pluginIDelay) return _pluginIDelay->controller(1)->curVal().f;
else {
printf("Warning : no DeicsOnze2 delay loaded\n");
return 0.0;
}
}
void DeicsOnze2::setDelayFeedback(float val) {
if(_pluginIDelay) return _pluginIDelay->controller(2)->setCurVal(val);
else printf("Warning : no DeicsOnze2 delay loaded\n");
}
float DeicsOnze2::getDelayFeedback() {
if(_pluginIDelay) return _pluginIDelay->controller(2)->curVal().f;
else {
printf("Warning : no DeicsOnze2 delay loaded\n");
return 0.0;
}
}
void DeicsOnze2::setDelayLFOFreq(float val) {
if(_pluginIDelay) _pluginIDelay->controller(3)->setCurVal(val);
else printf("Warning : no DeicsOnze2 delay loaded\n");
}
float DeicsOnze2::getDelayLFOFreq() {
if(_pluginIDelay) return _pluginIDelay->controller(3)->curVal().f;
else {
printf("Warning : no DeicsOnze2 delay loaded\n");
return 0.0;
}
}
void DeicsOnze2::setDelayLFODepth(float val) {
if(_pluginIDelay) _pluginIDelay->controller(4)->setCurVal(val);
else printf("Warning : no DeicsOnze2 delay loaded\n");
}
float DeicsOnze2::getDelayLFODepth() {
if(_pluginIDelay) return _pluginIDelay->controller(4)->curVal().f;
else {
printf("Warning : no DeicsOnze2 delay loaded\n");
return 0.0;
}
}
void DeicsOnze2::setDelayDryWet(float val) {
if(_pluginIDelay) _pluginIDelay->controller(5)->setCurVal(val);
else printf("Warning : no DeicsOnze2 delay loaded\n");
}
|