diff options
author | Nil Geisweiller <a-lin@sourceforge.net> | 2006-10-17 13:41:19 +0000 |
---|---|---|
committer | Nil Geisweiller <a-lin@sourceforge.net> | 2006-10-17 13:41:19 +0000 |
commit | 16cfc4acee835b7e99233de0102357492215000f (patch) | |
tree | f0479b0ee7965c1402d14da6c499a0cea6cc7ff4 | |
parent | 57385c162c09b56808d21eb29b803e6666f2c705 (diff) |
add deicsonzeplugin
-rw-r--r-- | muse/synti/deicsonze/TODO | 2 | ||||
-rw-r--r-- | muse/synti/deicsonze/deicsonzeplugin.cpp | 336 | ||||
-rw-r--r-- | muse/synti/deicsonze/deicsonzeplugin.h | 39 |
3 files changed, 376 insertions, 1 deletions
diff --git a/muse/synti/deicsonze/TODO b/muse/synti/deicsonze/TODO index 657af78c..34a75f67 100644 --- a/muse/synti/deicsonze/TODO +++ b/muse/synti/deicsonze/TODO @@ -3,7 +3,7 @@ - LFO Delay (bug) - Rate Scaling - Foot Control, Modulation Wheel, Breath Control, After Touch -- Reverb +- analogue reverb - Change presetName subcategoryName category with SysEx - Internal restructure, private vs public, add comment, etc - getPatchInfo... diff --git a/muse/synti/deicsonze/deicsonzeplugin.cpp b/muse/synti/deicsonze/deicsonzeplugin.cpp new file mode 100644 index 00000000..e08c6e7d --- /dev/null +++ b/muse/synti/deicsonze/deicsonzeplugin.cpp @@ -0,0 +1,336 @@ +//=========================================================================== +// +// DeicsOnze an emulator of the YAMAHA DX11 synthesizer +// +// Version 0.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 "plugin.h" +#include "plugingui.h" +#include "ctrl.h" +#include "muse/midi.h" +#include "awl/floatentry.h" +#include "awl/slider.h" +#include "awl/checkbox.h" +#include <QScrollArea> + +using Awl::FloatEntry; +using Awl::Slider; +using Awl::CheckBox; + +class PluginDialog; + +void DeicsOnze::initPluginReverb(Plugin* pluginReverb) { + //init plugin + if(_pluginIReverb) delete(_pluginIChorus); + _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); + } + + //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 DeicsOnze::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); + } + + //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 DeicsOnzeGui::addPluginCheckBox(int index, QString text, bool toggled, + QWidget* parent, QGridLayout* 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 DeicsOnzeGui::addPluginIntSlider(int index, QString text, double min, + double max, double val, QWidget* parent, + QGridLayout* grid, bool isReverb) { + addPluginSlider(index, text, false, min, max, val, parent, grid, isReverb); +} + +void DeicsOnzeGui::addPluginSlider(int index, QString text, bool isLog, + double min, double max, double val, + QWidget* parent, QGridLayout* 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->setValue(val); + s->setOrientation(Qt::Horizontal); + //s->setFixedHeight(h); + s->setRange(min, max); + 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 DeicsOnzeGui::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()); + QGridLayout* superLayout = new QGridLayout(parametersReverbGroupBox); + parametersReverbGroupBox->setLayout(superLayout); + //build super widget + if(_reverbSuperWidget) delete(_reverbSuperWidget); + _reverbSuperWidget = new QWidget(parametersReverbGroupBox); + superLayout->addWidget(_reverbSuperWidget); + //build scroll area + //QScrollArea* scrollArea = new QScrollArea; + //scrollArea->setBackgroundRole(QPalette::Dark); + //scrollArea->setWidget(_reverbSuperWidget); + //build grid + QGridLayout* grid = new QGridLayout(_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++) { + if(plugI->isBool(i)) + addPluginCheckBox(i, plugI->getParameterName(i), plugI->param(i) > 0.0, + _reverbSuperWidget, grid, true); + else if(plugI->isInt(i)) { + double min, max; + plugI->range(i, &min, &max); + addPluginIntSlider(i, plugI->getParameterName(i), rint(min), rint(max), + rint(plugI->param(i)), _reverbSuperWidget, grid, + true); + } + else { + double min, max; + plugI->range(i, &min, &max); + addPluginSlider(i, plugI->getParameterName(i), plugI->isLog(i), + min, max, plugI->param(i), _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 DeicsOnzeGui::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()); + QGridLayout* superLayout = new QGridLayout(parametersChorusGroupBox); + parametersChorusGroupBox->setLayout(superLayout); + //build super widget + if(_chorusSuperWidget) delete(_chorusSuperWidget); + _chorusSuperWidget = new QWidget(parametersChorusGroupBox); + superLayout->addWidget(_chorusSuperWidget); + //build grid + QGridLayout* grid = new QGridLayout(_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++) { + if(plugI->isBool(i)) + addPluginCheckBox(i, plugI->getParameterName(i), plugI->param(i) > 0.0, + _chorusSuperWidget, grid, false); + else if(plugI->isInt(i)) { + double min, max; + plugI->range(i, &min, &max); + addPluginIntSlider(i, plugI->getParameterName(i), + rint(min), rint(max), rint(plugI->param(i)), + _chorusSuperWidget, grid, false); + } + else { + double min, max; + plugI->range(i, &min, &max); + addPluginSlider(i, plugI->getParameterName(i), plugI->isLog(i), + min, max, plugI->param(i), + _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)); +} + +void DeicsOnzeGui::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)); + } +} + +void DeicsOnzeGui::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)); + } +} + + +void DeicsOnzeGui::setReverbFloatEntry(double v, int i) { + updateReverbSlider(v, i); + setReverbCheckBox(v, i); //because this send the SYSEX +} +void DeicsOnzeGui::setReverbSlider(double v, int i) { + updateReverbFloatEntry(v, i); + setReverbCheckBox(v, i); //because this send the SYSEX +} +void DeicsOnzeGui::setChorusFloatEntry(double v, int i) { + updateChorusSlider(v, i); + setChorusCheckBox(v, i); //because this send the SYSEX +} +void DeicsOnzeGui::setChorusSlider(double v, int i) { + updateChorusFloatEntry(v, i); + setChorusCheckBox(v, i); //because this send the SYSEX +} + +//updates +void DeicsOnzeGui::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 DeicsOnzeGui::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 DeicsOnzeGui::updateChorusSlider(double v, int i) { + if(i < (int)_reverbSliderVector.size() && _reverbSliderVector[i]) { + _reverbSliderVector[i]->blockSignals(true); + _reverbSliderVector[i]->setValue(v); + _reverbSliderVector[i]->blockSignals(false); + } +} +void DeicsOnzeGui::updateChorusFloatEntry(double v, int i) { + if(i < (int)_chorusFloatEntryVector.size() && _chorusFloatEntryVector[i]) { + _chorusFloatEntryVector[i]->blockSignals(true); + _chorusFloatEntryVector[i]->setValue(v); + _chorusFloatEntryVector[i]->blockSignals(false); + } +} diff --git a/muse/synti/deicsonze/deicsonzeplugin.h b/muse/synti/deicsonze/deicsonzeplugin.h new file mode 100644 index 00000000..3fd76e70 --- /dev/null +++ b/muse/synti/deicsonze/deicsonzeplugin.h @@ -0,0 +1,39 @@ +//=========================================================================== +// +// DeicsOnze an emulator of the YAMAHA DX11 synthesizer +// +// Version 0.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 __DEICSONZEPLUGIN_H +#define __DEICSONZEPLUGIN_H + +#include "deicsonze.h" +#include "deicsonzegui.h" + +class DeicsOnze; +class DeicsOnzeGui; + +#endif |