pull/1/head
asb2m10 11 years ago
parent 9b4b92753e
commit 0768632125
  1. BIN
      Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate
  2. 12
      Source/DXLookNFeel.cpp
  3. 2
      Source/PluginEditor.cpp
  4. 168
      Source/PluginParam.cpp

@ -25,27 +25,27 @@ void EnvDisplay::paint(Graphics &g) {
int rate[4]; int rate[4];
int level[4]; int level[4];
for(int i=0;i<4;i++) { for (int i = 0; i < 4; i++) {
rate[i] = s_rate[i]->getValue(); rate[i] = s_rate[i]->getValue();
level[i] = s_level[i]->getValue(); level[i] = s_level[i]->getValue();
} }
env.init(rate, level, 99 << 5, 0); env.init(rate, level, 99 << 5, 0);
env.keydown(true); env.keydown(true);
for (int i=0;i<72;i++) { for (int i = 0; i < 72; i++) {
int32_t pos = env.getsample(); int32_t pos = env.getsample();
for(int j=0;j<16;j++) { for (int j = 0; j < 16; j++) {
env.getsample(); env.getsample();
} }
g.setPixel(i, 32 - (sqrt(pos) / 512)); g.setPixel(i, 32 - (sqrt(pos) / 512));
} }
env.keydown(false); env.keydown(false);
for (int i=0;i<24;i++) { for (int i = 0; i < 24; i++) {
int32_t pos = env.getsample(); int32_t pos = env.getsample();
for(int j=0;j<16;j++) { for (int j = 0; j < 16; j++) {
env.getsample(); env.getsample();
} }
g.setPixel(i+72, 32 - (sqrt(pos) / 512)); g.setPixel(i + 72, 32 - (sqrt(pos) / 512));
} }
} }

@ -182,7 +182,7 @@ void DexedAudioProcessorEditor::timerCallback() {
return; return;
for(int i=0;i<6;i++) { for(int i=0;i<6;i++) {
operators[i].updateGain(sqrt(env[5-i]) / 8196); operators[i].updateGain(sqrt(env[5 - i]) / 8196);
} }
} }

@ -49,27 +49,26 @@ void Ctrl::bind(ComboBox *c) {
} }
void Ctrl::unbind() { void Ctrl::unbind() {
if ( slider != NULL ) { if (slider != NULL) {
slider->removeListener(this); slider->removeListener(this);
slider = NULL; slider = NULL;
} }
if ( button != NULL ) { if (button != NULL) {
button->removeListener(this); button->removeListener(this);
button = NULL; button = NULL;
} }
if ( comboBox != NULL ) { if (comboBox != NULL) {
comboBox->removeListener(this); comboBox->removeListener(this);
comboBox = NULL; comboBox = NULL;
} }
} }
// ************************************************************************ // ************************************************************************
// CtrlInt ================================================================ // CtrlInt ================================================================
CtrlDX::CtrlDX(String name, int steps, int offset, bool starts1) : CtrlDX::CtrlDX(String name, int steps, int offset, bool starts1) :
Ctrl(name) { Ctrl(name) {
add1 = starts1 == 1; add1 = starts1 == 1;
this->steps = steps; this->steps = steps;
value = 0; value = 0;
@ -85,19 +84,19 @@ void CtrlDX::setValuePlugin(float f) {
} }
void CtrlDX::setValue(int v) { void CtrlDX::setValue(int v) {
if ( v >= steps ) { if (v >= steps) {
TRACE("WARNING: value too big %s : %d", label.toRawUTF8(), v); TRACE("WARNING: value too big %s : %d", label.toRawUTF8(), v);
v = steps-1; v = steps - 1;
} }
value = v; value = v;
if ( dxOffset >= 0 ) { if (dxOffset >= 0) {
if ( parent != NULL ) if (parent != NULL)
parent->setDxValue(dxOffset, v); parent->setDxValue(dxOffset, v);
} }
} }
int CtrlDX::getValue() { int CtrlDX::getValue() {
if ( dxOffset >= 0 ) if (dxOffset >= 0)
value = parent->data[dxOffset]; value = parent->data[dxOffset];
return value; return value;
} }
@ -110,39 +109,42 @@ String CtrlDX::getValueDisplay() {
void CtrlDX::publishValue(int value) { void CtrlDX::publishValue(int value) {
parent->beginParameterChangeGesture(idx); parent->beginParameterChangeGesture(idx);
parent->setParameterNotifyingHost(idx, (((float)value) / steps)); parent->setParameterNotifyingHost(idx, (((float) value) / steps));
parent->endParameterChangeGesture(idx); parent->endParameterChangeGesture(idx);
} }
void CtrlDX::sliderValueChanged(Slider* moved) { void CtrlDX::sliderValueChanged(Slider* moved) {
publishValue(((int)moved->getValue() - add1)); publishValue(((int) moved->getValue() - add1));
} }
void CtrlDX::buttonClicked (Button* clicked) { void CtrlDX::buttonClicked(Button* clicked) {
publishValue(clicked->getToggleStateValue() == 1 ? 1 : 0); publishValue(clicked->getToggleStateValue() == 1 ? 1 : 0);
} }
void CtrlDX::comboBoxChanged (ComboBox* combo) { void CtrlDX::comboBoxChanged(ComboBox* combo) {
publishValue(combo->getSelectedId()-1); publishValue(combo->getSelectedId() - 1);
} }
void CtrlDX::updateComponent() { void CtrlDX::updateComponent() {
//TRACE("setting for %s %d", label.toRawUTF8(), getValue()); //TRACE("setting for %s %d", label.toRawUTF8(), getValue());
if ( slider != NULL ) { if (slider != NULL) {
slider->setValue(getValue() + add1, NotificationType::dontSendNotification); slider->setValue(getValue() + add1,
NotificationType::dontSendNotification);
} }
if ( button != NULL ) { if (button != NULL) {
if ( getValue() == 0 ) { if (getValue() == 0) {
button->setToggleState(false, NotificationType::dontSendNotification); button->setToggleState(false,
NotificationType::dontSendNotification);
} else { } else {
button->setToggleState(true, NotificationType::dontSendNotification); button->setToggleState(true,
NotificationType::dontSendNotification);
} }
} }
if ( comboBox != NULL ) { if (comboBox != NULL) {
int cvalue = getValue() + 1; int cvalue = getValue() + 1;
if ( comboBox->getNumItems() <= cvalue ) { if (comboBox->getNumItems() <= cvalue) {
cvalue = comboBox->getNumItems(); cvalue = comboBox->getNumItems();
} }
comboBox->setSelectedId(cvalue, NotificationType::dontSendNotification); comboBox->setSelectedId(cvalue, NotificationType::dontSendNotification);
@ -155,88 +157,92 @@ void DexedAudioProcessor::initCtrl() {
importSysex(BinaryData::startup_syx); importSysex(BinaryData::startup_syx);
// fill operator values; // fill operator values;
for(int i=0;i<6;i++) { for (int i = 0; i < 6; i++) {
//// In the Sysex, OP6 comes first, then OP5... //// In the Sysex, OP6 comes first, then OP5...
//int opTarget = (5-i) * 21; //int opTarget = (5-i) * 21;
int opTarget = i * 21; int opTarget = i * 21;
int opVal = 5-i; int opVal = 5 - i;
String opName; String opName;
opName << "OP" << (opVal+1); opName << "OP" << (opVal + 1);
for(int j=0;j<4;j++) { for (int j = 0; j < 4; j++) {
String opRate; String opRate;
opRate << opName << "-EGR" << (j+1); opRate << opName << "-EGR" << (j + 1);
opCtrl[opVal].egRate[j] = new CtrlDX(opRate, 100, opTarget+j); opCtrl[opVal].egRate[j] = new CtrlDX(opRate, 100, opTarget + j);
ctrl.add(opCtrl[opVal].egRate[j]); ctrl.add(opCtrl[opVal].egRate[j]);
String opLevel; String opLevel;
opLevel << opName << "-EGL" << (j+1); opLevel << opName << "-EGL" << (j + 1);
opCtrl[opVal].egLevel[j] = new CtrlDX(opLevel, 100, opTarget+j+4); opCtrl[opVal].egLevel[j] = new CtrlDX(opLevel, 100,
opTarget + j + 4);
ctrl.add(opCtrl[opVal].egLevel[j]); ctrl.add(opCtrl[opVal].egLevel[j]);
} }
String opVol; String opVol;
opVol << opName << "-LEVEL"; opVol << opName << "-LEVEL";
opCtrl[opVal].level = new CtrlDX(opVol, 100, opTarget+16); opCtrl[opVal].level = new CtrlDX(opVol, 100, opTarget + 16);
ctrl.add(opCtrl[opVal].level); ctrl.add(opCtrl[opVal].level);
String opMode; String opMode;
opMode << opName << "-MODE"; opMode << opName << "-MODE";
opCtrl[opVal].opMode = new CtrlDX(opMode, 1, opTarget+17); opCtrl[opVal].opMode = new CtrlDX(opMode, 1, opTarget + 17);
ctrl.add(opCtrl[opVal].opMode); ctrl.add(opCtrl[opVal].opMode);
String coarse; String coarse;
coarse << opName << "-COARSE"; coarse << opName << "-COARSE";
opCtrl[opVal].coarse = new CtrlDX(coarse, 32, opTarget+18); opCtrl[opVal].coarse = new CtrlDX(coarse, 32, opTarget + 18);
ctrl.add(opCtrl[opVal].coarse); ctrl.add(opCtrl[opVal].coarse);
String fine; String fine;
fine << opName << "-FINE"; fine << opName << "-FINE";
opCtrl[opVal].fine = new CtrlDX(fine, 100, opTarget+19); opCtrl[opVal].fine = new CtrlDX(fine, 100, opTarget + 19);
ctrl.add(opCtrl[opVal].fine); ctrl.add(opCtrl[opVal].fine);
String detune; String detune;
detune << opName << "-DETUNE"; detune << opName << "-DETUNE";
opCtrl[opVal].detune = new CtrlDX(detune, 15, opTarget+20); opCtrl[opVal].detune = new CtrlDX(detune, 15, opTarget + 20);
ctrl.add(opCtrl[opVal].detune); ctrl.add(opCtrl[opVal].detune);
String sclBrkPt; String sclBrkPt;
sclBrkPt << opName << "-SCL_BRK_PNT"; sclBrkPt << opName << "-SCL_BRK_PNT";
opCtrl[opVal].sclBrkPt = new CtrlDX(sclBrkPt, 100, opTarget+8); opCtrl[opVal].sclBrkPt = new CtrlDX(sclBrkPt, 100, opTarget + 8);
ctrl.add(opCtrl[opVal].sclBrkPt); ctrl.add(opCtrl[opVal].sclBrkPt);
String sclLeftDepth; String sclLeftDepth;
sclLeftDepth << opName << "-SCL_LFT_DEPTH"; sclLeftDepth << opName << "-SCL_LFT_DEPTH";
opCtrl[opVal].sclLeftDepth = new CtrlDX(sclLeftDepth, 100, opTarget+9); opCtrl[opVal].sclLeftDepth = new CtrlDX(sclLeftDepth, 100,
opTarget + 9);
ctrl.add(opCtrl[opVal].sclLeftDepth); ctrl.add(opCtrl[opVal].sclLeftDepth);
String sclRightDepth; String sclRightDepth;
sclRightDepth << opName << "-SCL_RHT_DEPTH"; sclRightDepth << opName << "-SCL_RHT_DEPTH";
opCtrl[opVal].sclRightDepth = new CtrlDX(sclRightDepth, 100, opTarget+10); opCtrl[opVal].sclRightDepth = new CtrlDX(sclRightDepth, 100,
opTarget + 10);
ctrl.add(opCtrl[opVal].sclRightDepth); ctrl.add(opCtrl[opVal].sclRightDepth);
String sclLeftCurve; String sclLeftCurve;
sclLeftCurve << opName << "-SCL_LFT_CURVE"; sclLeftCurve << opName << "-SCL_LFT_CURVE";
opCtrl[opVal].sclLeftCurve = new CtrlDX(sclLeftCurve, 4, opTarget+11); opCtrl[opVal].sclLeftCurve = new CtrlDX(sclLeftCurve, 4, opTarget + 11);
ctrl.add(opCtrl[opVal].sclLeftCurve); ctrl.add(opCtrl[opVal].sclLeftCurve);
String sclRightCurve; String sclRightCurve;
sclRightCurve << opName << "-SCL_RHT_CURVE"; sclRightCurve << opName << "-SCL_RHT_CURVE";
opCtrl[opVal].sclRightCurve = new CtrlDX(sclRightCurve, 4, opTarget+12); opCtrl[opVal].sclRightCurve = new CtrlDX(sclRightCurve, 4,
opTarget + 12);
ctrl.add(opCtrl[opVal].sclRightCurve); ctrl.add(opCtrl[opVal].sclRightCurve);
String sclRate; String sclRate;
sclRate << opName << "-SCL_RATE"; sclRate << opName << "-SCL_RATE";
opCtrl[opVal].sclRate = new CtrlDX(sclRate, 7, opTarget+13); opCtrl[opVal].sclRate = new CtrlDX(sclRate, 7, opTarget + 13);
ctrl.add(opCtrl[opVal].sclRate); ctrl.add(opCtrl[opVal].sclRate);
String ampModSens; String ampModSens;
ampModSens << opName << "-AMP_MODSENS"; ampModSens << opName << "-AMP_MODSENS";
opCtrl[opVal].ampModSens = new CtrlDX(ampModSens, 3, opTarget+14); opCtrl[opVal].ampModSens = new CtrlDX(ampModSens, 3, opTarget + 14);
ctrl.add(opCtrl[opVal].ampModSens); ctrl.add(opCtrl[opVal].ampModSens);
String velModSens; String velModSens;
velModSens << opName << "-VEL_MODSENS"; velModSens << opName << "-VEL_MODSENS";
opCtrl[opVal].velModSens = new CtrlDX(velModSens, 8, opTarget+15); opCtrl[opVal].velModSens = new CtrlDX(velModSens, 8, opTarget + 15);
ctrl.add(opCtrl[opVal].velModSens); ctrl.add(opCtrl[opVal].velModSens);
} }
@ -261,25 +267,32 @@ void DexedAudioProcessor::initCtrl() {
lfoWaveform = new CtrlDX("LFO-Waveform", 5, 142); lfoWaveform = new CtrlDX("LFO-Waveform", 5, 142);
ctrl.add(lfoWaveform); ctrl.add(lfoWaveform);
for(int i=0;i<ctrl.size();i++) { for (int i = 0; i < ctrl.size(); i++) {
ctrl[i]->idx = i; ctrl[i]->idx = i;
ctrl[i]->parent = this; ctrl[i]->parent = this;
} }
} }
int DexedAudioProcessor::importSysex(const char *imported) { int DexedAudioProcessor::importSysex(const char *imported) {
memcpy(sysex, imported+6, 4104); memcpy(sysex, imported + 6, 4104);
for(int i=0;i<32;i++) { for (int i = 0; i < 32; i++) {
memcpy(patchNames[i], sysex + ((i*128)+118), 11); memcpy(patchNames[i], sysex + ((i * 128) + 118), 11);
for(int j=0;j<10;j++) { for (int j = 0; j < 10; j++) {
char c = (unsigned char)patchNames[i][j]; char c = (unsigned char) patchNames[i][j];
switch (c) { switch (c) {
case 92: c = 'Y'; break; /* yen */ case 92:
case 126: c = '>'; break; /* >> */ c = 'Y';
case 127: c = '<'; break; /* << */ break; /* yen */
case 126:
c = '>';
break; /* >> */
case 127:
c = '<';
break; /* << */
default: default:
if (c < 32 || c > 127) c = 32; if (c < 32 || c > 127)
c = 32;
break; break;
} }
patchNames[i][j] = c; patchNames[i][j] = c;
@ -328,7 +341,6 @@ void DexedAudioProcessor::unpackProgram(int idx) {
data[160] = 1; data[160] = 1;
} }
void DexedAudioProcessor::updateProgramFromSysex(const uint8 *rawdata) { void DexedAudioProcessor::updateProgramFromSysex(const uint8 *rawdata) {
} }
@ -336,10 +348,10 @@ void DexedAudioProcessor::updateProgramFromSysex(const uint8 *rawdata) {
void DexedAudioProcessor::setDxValue(int offset, int v) { void DexedAudioProcessor::setDxValue(int offset, int v) {
TRACE("setting dx %d %d", offset, v); TRACE("setting dx %d %d", offset, v);
refreshVoice = true; refreshVoice = true;
if ( offset >= 0 ) if (offset >= 0)
data[offset] = v; data[offset] = v;
if ( !sendSysexChange ) if (!sendSysexChange)
return; return;
uint8 msg[7] = { 0xF0, 0x43, 0x10, offset > 127, 0, (uint8) v, 0xF7 }; uint8 msg[7] = { 0xF0, 0x43, 0x10, offset > 127, 0, (uint8) v, 0xF7 };
msg[4] = offset & 0x7F; msg[4] = offset & 0x7F;
@ -347,7 +359,7 @@ void DexedAudioProcessor::setDxValue(int offset, int v) {
} }
void DexedAudioProcessor::unbindUI() { void DexedAudioProcessor::unbindUI() {
for(int i=0;i<ctrl.size();i++) { for (int i = 0; i < ctrl.size(); i++) {
ctrl[i]->unbind(); ctrl[i]->unbind();
} }
} }
@ -357,11 +369,11 @@ int DexedAudioProcessor::getNumParameters() {
return ctrl.size(); return ctrl.size();
} }
float DexedAudioProcessor::getParameter (int index) { float DexedAudioProcessor::getParameter(int index) {
return ctrl[index]->getValuePlugin(); return ctrl[index]->getValuePlugin();
} }
void DexedAudioProcessor::setParameter (int index, float newValue) { void DexedAudioProcessor::setParameter(int index, float newValue) {
ctrl[index]->setValuePlugin(newValue); ctrl[index]->setValuePlugin(newValue);
} }
@ -373,15 +385,15 @@ int DexedAudioProcessor::getCurrentProgram() {
return currentProgram; return currentProgram;
} }
void DexedAudioProcessor::setCurrentProgram (int index) { void DexedAudioProcessor::setCurrentProgram(int index) {
/*// VST has a naughty problem of calling setCurrentProgram after a host has loaded /*// VST has a naughty problem of calling setCurrentProgram after a host has loaded
// an edited preset. We ignore the 16th value, since we want to keep the user values // an edited preset. We ignore the 16th value, since we want to keep the user values
if ( index == 32 ) { if ( index == 32 ) {
return; return;
}*/ }*/
for(int i=0;i<MAX_ACTIVE_NOTES;i++) { for (int i = 0; i < MAX_ACTIVE_NOTES; i++) {
if ( voices[i].keydown == false && voices[i].live == true ) { if (voices[i].keydown == false && voices[i].live == true) {
voices[i].live = false; voices[i].live = false;
} }
} }
@ -392,50 +404,48 @@ void DexedAudioProcessor::setCurrentProgram (int index) {
updateUI(); updateUI();
} }
const String DexedAudioProcessor::getProgramName (int index) { const String DexedAudioProcessor::getProgramName(int index) {
if ( index >= 32 ) if (index >= 32)
index = 31; index = 31;
return String(patchNames[index]); return String(patchNames[index]);
} }
void DexedAudioProcessor::changeProgramName (int index, const String& newName) { void DexedAudioProcessor::changeProgramName(int index, const String& newName) {
} }
const String DexedAudioProcessor::getParameterName(int index) {
const String DexedAudioProcessor::getParameterName (int index) {
return ctrl[index]->label; return ctrl[index]->label;
} }
const String DexedAudioProcessor::getParameterText (int index) { const String DexedAudioProcessor::getParameterText(int index) {
return ctrl[index]->getValueDisplay(); return ctrl[index]->getValueDisplay();
} }
//============================================================================== //==============================================================================
void DexedAudioProcessor::getStateInformation (MemoryBlock& destData) { void DexedAudioProcessor::getStateInformation(MemoryBlock& destData) {
// You should use this method to store your parameters in the memory block. // You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes // You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.*/ // as intermediaries to make it easy to save and load complex data.*/
destData.insert(data, 161, 0); destData.insert(data, 161, 0);
} }
void DexedAudioProcessor::setStateInformation (const void* source, int sizeInBytes) { void DexedAudioProcessor::setStateInformation(const void* source,
int sizeInBytes) {
// You should use this method to restore your parameters from this memory block, // You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call. // whose contents will have been created by the getStateInformation() call.
memcpy((void *)data, source, sizeInBytes); memcpy((void *) data, source, sizeInBytes);
updateUI(); updateUI();
} }
//============================================================================== //==============================================================================
void DexedAudioProcessor::getCurrentProgramStateInformation (MemoryBlock& destData) { void DexedAudioProcessor::getCurrentProgramStateInformation(
MemoryBlock& destData) {
destData.insert(data, 161, 0); destData.insert(data, 161, 0);
} }
void DexedAudioProcessor::setCurrentProgramStateInformation (const void* source, int sizeInBytes) { void DexedAudioProcessor::setCurrentProgramStateInformation(const void* source,
memcpy((void *)data, source, sizeInBytes); int sizeInBytes) {
memcpy((void *) data, source, sizeInBytes);
updateUI(); updateUI();
} }

Loading…
Cancel
Save