pull/1/head
asb2m10 11 years ago
parent 5b8add06dd
commit 9b6c3143f8
  1. BIN
      Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate
  2. 24
      Source/PluginEditor.cpp
  3. 352
      Source/PluginParam.cpp
  4. 36
      Source/PluginParam.h
  5. 18
      Source/PluginProcessor.cpp

@ -49,7 +49,7 @@ DexedAudioProcessorEditor::DexedAudioProcessorEditor (DexedAudioProcessor* owner
presets.setBounds(200, 5, 150, 24);
for(int i=0;i<processor->getNumPrograms();i++) {
presets.addItem( processor->getProgramName(i), i+1);
presets.addItem( processor->getProgramName(i), i+1);
}
presets.setSelectedId(processor->getCurrentProgram()+1, NotificationType::dontSendNotification);
presets.addListener(this);
@ -98,7 +98,7 @@ DexedAudioProcessorEditor::DexedAudioProcessorEditor (DexedAudioProcessor* owner
DexedAudioProcessorEditor::~DexedAudioProcessorEditor() {
stopTimer();
processor->unbindUI();
processor->unbindUI();
}
//==============================================================================
@ -134,7 +134,7 @@ void DexedAudioProcessorEditor::buttonClicked(Button *buttonThatWasClicked) {
presets.clear(NotificationType::dontSendNotification);
for(int i=0;i<processor->getNumPrograms();i++) {
presets.addItem(processor->getProgramName(i), i+1);
presets.addItem(processor->getProgramName(i), i+1);
}
TRACE("selecting id %d", processor->getCurrentProgram());
presets.setSelectedId(processor->getCurrentProgram()+1, NotificationType::dontSendNotification);
@ -148,12 +148,12 @@ void DexedAudioProcessorEditor::sliderValueChanged (Slider* slider) {
}
void DexedAudioProcessorEditor::comboBoxChanged (ComboBox* comboBoxThatHasChanged) {
processor->setCurrentProgram(comboBoxThatHasChanged->getSelectedId()-1);
processor->setCurrentProgram(comboBoxThatHasChanged->getSelectedId()-1);
processor->updateHostDisplay();
}
void DexedAudioProcessorEditor::timerCallback() {
int32_t env[6];
int32_t env[6];
if ( processor->peekEnvStatus(env) == false )
return;
@ -164,11 +164,11 @@ void DexedAudioProcessorEditor::timerCallback() {
}
void DexedAudioProcessorEditor::updateUI() {
TRACE("update UI called");
for(int i=0;i<processor->ctrl.size();i++) {
processor->ctrl[i]->updateComponent();
}
for(int i=0;i<6;i++) {
ops[i].updateFreqDisplay();
}
TRACE("update UI called");
for(int i=0;i<processor->ctrl.size();i++) {
processor->ctrl[i]->updateComponent();
}
for(int i=0;i<6;i++) {
ops[i].updateFreqDisplay();
}
}

@ -24,45 +24,45 @@
// ************************************************************************
//
Ctrl::Ctrl(String name) {
label << name;
slider = NULL;
button = NULL;
comboBox = NULL;
label << name;
slider = NULL;
button = NULL;
comboBox = NULL;
}
void Ctrl::bind(Slider *s) {
slider = s;
updateComponent();
s->addListener(this);
slider = s;
updateComponent();
s->addListener(this);
}
void Ctrl::bind(Button *b) {
button = b;
updateComponent();
b->addListener(this);
button = b;
updateComponent();
b->addListener(this);
}
void Ctrl::bind(ComboBox *c) {
comboBox = c;
updateComponent();
c->addListener(this);
comboBox = c;
updateComponent();
c->addListener(this);
}
void Ctrl::unbind() {
if ( slider != NULL ) {
slider->removeListener(this);
slider = NULL;
}
if ( slider != NULL ) {
slider->removeListener(this);
slider = NULL;
}
if ( button != NULL ) {
button->removeListener(this);
button = NULL;
}
if ( button != NULL ) {
button->removeListener(this);
button = NULL;
}
if ( comboBox != NULL ) {
comboBox->removeListener(this);
comboBox = NULL;
}
if ( comboBox != NULL ) {
comboBox->removeListener(this);
comboBox = NULL;
}
}
@ -70,83 +70,83 @@ void Ctrl::unbind() {
// CtrlInt ================================================================
CtrlInt::CtrlInt(String name, int steps, int offset, bool starts1) :
Ctrl(name) {
add1 = starts1 == 1;
this->steps = steps;
value = 0;
dxOffset = offset;
add1 = starts1 == 1;
this->steps = steps;
value = 0;
dxOffset = offset;
}
float CtrlInt::getValuePlugin() {
return value / steps;
return value / steps;
}
void CtrlInt::setValuePlugin(float f) {
setValue((f * steps));
setValue((f * steps));
}
void CtrlInt::setValue(int v) {
if ( v >= steps ) {
TRACE("WARNING: value too big %s : %d", label.toRawUTF8(), v);
v = steps-1;
}
value = v;
if ( dxOffset >= 0 ) {
if ( parent != NULL )
parent->setDxValue(dxOffset, v);
}
if ( v >= steps ) {
TRACE("WARNING: value too big %s : %d", label.toRawUTF8(), v);
v = steps-1;
}
value = v;
if ( dxOffset >= 0 ) {
if ( parent != NULL )
parent->setDxValue(dxOffset, v);
}
}
int CtrlInt::getValue() {
if ( dxOffset >= 0 )
value = parent->data[dxOffset];
return value;
if ( dxOffset >= 0 )
value = parent->data[dxOffset];
return value;
}
String CtrlInt::getValueDisplay() {
String ret;
ret << getValue();
return ret;
String ret;
ret << getValue();
return ret;
}
void CtrlInt::publishValue(int value) {
parent->beginParameterChangeGesture(idx);
parent->setParameterNotifyingHost(idx, (((float)value) / steps));
parent->endParameterChangeGesture(idx);
parent->beginParameterChangeGesture(idx);
parent->setParameterNotifyingHost(idx, (((float)value) / steps));
parent->endParameterChangeGesture(idx);
}
void CtrlInt::sliderValueChanged(Slider* moved) {
publishValue(((int)moved->getValue() - add1));
publishValue(((int)moved->getValue() - add1));
}
void CtrlInt::buttonClicked (Button* clicked) {
publishValue(clicked->getToggleStateValue() == 1 ? 1 : 0);
publishValue(clicked->getToggleStateValue() == 1 ? 1 : 0);
}
void CtrlInt::comboBoxChanged (ComboBox* combo) {
publishValue(combo->getSelectedId()-1);
publishValue(combo->getSelectedId()-1);
}
void CtrlInt::updateComponent() {
//TRACE("setting for %s %d", label.toRawUTF8(), getValue());
if ( slider != NULL ) {
slider->setValue(getValue() + add1, NotificationType::dontSendNotification);
}
//TRACE("setting for %s %d", label.toRawUTF8(), getValue());
if ( slider != NULL ) {
slider->setValue(getValue() + add1, NotificationType::dontSendNotification);
}
if ( button != NULL ) {
if ( getValue() == 0 ) {
button->setToggleState(false, NotificationType::dontSendNotification);
} else {
button->setToggleState(true, NotificationType::dontSendNotification);
}
}
if ( button != NULL ) {
if ( getValue() == 0 ) {
button->setToggleState(false, NotificationType::dontSendNotification);
} else {
button->setToggleState(true, NotificationType::dontSendNotification);
}
}
if ( comboBox != NULL ) {
int cvalue = getValue() + 1;
if ( comboBox->getNumItems() <= cvalue ) {
cvalue = comboBox->getNumItems();
}
comboBox->setSelectedId(cvalue, NotificationType::dontSendNotification);
}
if ( comboBox != NULL ) {
int cvalue = getValue() + 1;
if ( comboBox->getNumItems() <= cvalue ) {
cvalue = comboBox->getNumItems();
}
comboBox->setSelectedId(cvalue, NotificationType::dontSendNotification);
}
}
// ************************************************************************
@ -156,46 +156,46 @@ void DexedAudioProcessor::initCtrl() {
// fill operator values;
for(int i=0;i<6;i++) {
// In the Sysex, OP6 comes first, then OP5...
//int opTarget = (5-i) * 21;
// In the Sysex, OP6 comes first, then OP5...
int opTarget = i * 21;
for(int j=0;j<4;j++) {
String opRate;
opRate << "OP" << (i+1) << "-EGR" << (j+1);
opCtrl[i].egRate[j] = new CtrlInt(opRate, 100, opTarget+j);
ctrl.add(opCtrl[i].egRate[j]);
// In the Sysex, OP6 comes first, then OP5...
//int opTarget = (5-i) * 21;
// In the Sysex, OP6 comes first, then OP5...
int opTarget = i * 21;
for(int j=0;j<4;j++) {
String opRate;
opRate << "OP" << (i+1) << "-EGR" << (j+1);
opCtrl[i].egRate[j] = new CtrlInt(opRate, 100, opTarget+j);
ctrl.add(opCtrl[i].egRate[j]);
String opLevel;
opLevel << "OP" << (i+1) << "-EGL" << (j+1);
opCtrl[i].egLevel[j] = new CtrlInt(opLevel, 100, opTarget+j+4);
ctrl.add(opCtrl[i].egLevel[j]);
}
String opVol;
opVol << "OP" << (i+1) << "-LEVEL";
opCtrl[i].level = new CtrlInt(opVol, 100, opTarget+16);
ctrl.add(opCtrl[i].level);
String opLevel;
opLevel << "OP" << (i+1) << "-EGL" << (j+1);
opCtrl[i].egLevel[j] = new CtrlInt(opLevel, 100, opTarget+j+4);
ctrl.add(opCtrl[i].egLevel[j]);
}
String opVol;
opVol << "OP" << (i+1) << "-LEVEL";
opCtrl[i].level = new CtrlInt(opVol, 100, opTarget+16);
ctrl.add(opCtrl[i].level);
String opMode;
opMode << "OP" << (i+1) << "-MODE";
opCtrl[i].opMode = new CtrlInt(opMode, 1, opTarget+17);
ctrl.add(opCtrl[i].opMode);
String opMode;
opMode << "OP" << (i+1) << "-MODE";
opCtrl[i].opMode = new CtrlInt(opMode, 1, opTarget+17);
ctrl.add(opCtrl[i].opMode);
String coarse;
coarse << "OP" << (i+1) << "-COARSE";
opCtrl[i].coarse = new CtrlInt(coarse, 32, opTarget+18, true);
ctrl.add(opCtrl[i].coarse);
String coarse;
coarse << "OP" << (i+1) << "-COARSE";
opCtrl[i].coarse = new CtrlInt(coarse, 32, opTarget+18, true);
ctrl.add(opCtrl[i].coarse);
String fine;
fine << "OP" << (i+1) << "-FINE";
opCtrl[i].fine = new CtrlInt(fine, 100, opTarget+19);
ctrl.add(opCtrl[i].fine);
String detune;
detune << "OP" << (i+1) << "-DETUNE";
opCtrl[i].detune = new CtrlInt(detune, 15, opTarget+20);
ctrl.add(opCtrl[i].detune);
String fine;
fine << "OP" << (i+1) << "-FINE";
opCtrl[i].fine = new CtrlInt(fine, 100, opTarget+19);
ctrl.add(opCtrl[i].fine);
String detune;
detune << "OP" << (i+1) << "-DETUNE";
opCtrl[i].detune = new CtrlInt(detune, 15, opTarget+20);
ctrl.add(opCtrl[i].detune);
}
algo = new CtrlInt("Algorithm", 32, 134, true);
@ -207,8 +207,8 @@ void DexedAudioProcessor::initCtrl() {
lfoDelay = new CtrlInt("LFO-Delay", 100, 138);
ctrl.add(lfoDelay);
lfoPitchDepth = new CtrlInt("LFO-PitchDepth", 100, 139);
ctrl.add(lfoPitchDepth);
lfoPitchDepth = new CtrlInt("LFO-PitchDepth", 100, 139);
ctrl.add(lfoPitchDepth);
lfoAmpDepth = new CtrlInt("LFO-AmpDepth", 100, 140);
ctrl.add(lfoAmpDepth);
@ -220,8 +220,8 @@ void DexedAudioProcessor::initCtrl() {
ctrl.add(lfoWaveform);
for(int i=0;i<ctrl.size();i++) {
ctrl[i]->idx = i;
ctrl[i]->parent = this;
ctrl[i]->idx = i;
ctrl[i]->parent = this;
}
}
@ -240,63 +240,63 @@ int DexedAudioProcessor::importSysex(const char *imported) {
if (c < 32 || c > 127) c = 32;
break;
}
patchNames[i][j] = c;
patchNames[i][j] = c;
}
patchNames[i][11] = 0;
}
return 0;
return 0;
}
void DexedAudioProcessor::unpackSysex(int idx) {
char *bulk = sysex + (idx * 128);
char *bulk = sysex + (idx * 128);
for (int op = 0; op < 6; op++) {
// eg rate and level, brk pt, depth, scaling
memcpy(data + op * 21, bulk + op * 17, 11);
char leftrightcurves = bulk[op * 17 + 11];
data[op * 21 + 11] = leftrightcurves & 3;
data[op * 21 + 12] = (leftrightcurves >> 2) & 3;
char detune_rs = bulk[op * 17 + 12];
data[op * 21 + 13] = detune_rs & 7;
char kvs_ams = bulk[op * 17 + 13];
data[op * 21 + 14] = kvs_ams & 3;
data[op * 21 + 15] = kvs_ams >> 2;
data[op * 21 + 16] = bulk[op * 17 + 14]; // output level
char fcoarse_mode = bulk[op * 17 + 15];
data[op * 21 + 17] = fcoarse_mode & 1;
data[op * 21 + 18] = fcoarse_mode >> 1;
data[op * 21 + 19] = bulk[op * 17 + 16]; // fine freq
data[op * 21 + 20] = detune_rs >> 3;
}
memcpy(data + 126, bulk + 102, 9); // pitch env, algo
char oks_fb = bulk[111];
data[135] = oks_fb & 7;
data[136] = oks_fb >> 3;
memcpy(data + 137, bulk + 112, 4); // lfo
char lpms_lfw_lks = bulk[116];
data[141] = lpms_lfw_lks & 1;
data[142] = (lpms_lfw_lks >> 1) & 7;
data[143] = lpms_lfw_lks >> 4;
memcpy(data + 144, bulk + 117, 11); // transpose, name
data[155] = 1; // operator on/off
data[156] = 1;
data[157] = 1;
data[158] = 1;
data[159] = 1;
data[160] = 1;
for (int op = 0; op < 6; op++) {
// eg rate and level, brk pt, depth, scaling
memcpy(data + op * 21, bulk + op * 17, 11);
char leftrightcurves = bulk[op * 17 + 11];
data[op * 21 + 11] = leftrightcurves & 3;
data[op * 21 + 12] = (leftrightcurves >> 2) & 3;
char detune_rs = bulk[op * 17 + 12];
data[op * 21 + 13] = detune_rs & 7;
char kvs_ams = bulk[op * 17 + 13];
data[op * 21 + 14] = kvs_ams & 3;
data[op * 21 + 15] = kvs_ams >> 2;
data[op * 21 + 16] = bulk[op * 17 + 14]; // output level
char fcoarse_mode = bulk[op * 17 + 15];
data[op * 21 + 17] = fcoarse_mode & 1;
data[op * 21 + 18] = fcoarse_mode >> 1;
data[op * 21 + 19] = bulk[op * 17 + 16]; // fine freq
data[op * 21 + 20] = detune_rs >> 3;
}
memcpy(data + 126, bulk + 102, 9); // pitch env, algo
char oks_fb = bulk[111];
data[135] = oks_fb & 7;
data[136] = oks_fb >> 3;
memcpy(data + 137, bulk + 112, 4); // lfo
char lpms_lfw_lks = bulk[116];
data[141] = lpms_lfw_lks & 1;
data[142] = (lpms_lfw_lks >> 1) & 7;
data[143] = lpms_lfw_lks >> 4;
memcpy(data + 144, bulk + 117, 11); // transpose, name
data[155] = 1; // operator on/off
data[156] = 1;
data[157] = 1;
data[158] = 1;
data[159] = 1;
data[160] = 1;
}
void DexedAudioProcessor::setDxValue(int offset, int v) {
TRACE("setting dx %d %d", offset, v);
isDirty = true;
if ( offset >= 0 )
data[offset] = v;
TRACE("setting dx %d %d", offset, v);
isDirty = true;
if ( offset >= 0 )
data[offset] = v;
}
void DexedAudioProcessor::unbindUI() {
for(int i=0;i<ctrl.size();i++) {
ctrl[i]->unbind();
for(int i=0;i<ctrl.size();i++) {
ctrl[i]->unbind();
}
}
@ -314,36 +314,36 @@ void DexedAudioProcessor::setParameter (int index, float newValue) {
}
int DexedAudioProcessor::getNumPrograms() {
// there is 32 program, the 33th one is a ghost for saving "unsaved" preset.
// there is 32 program, the 33th one is a ghost for saving "unsaved" preset.
return 32;
}
int DexedAudioProcessor::getCurrentProgram() {
return currentProgram;
return currentProgram;
}
void DexedAudioProcessor::setCurrentProgram (int index) {
/*// 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
if ( index == 32 ) {
return;
}*/
for(int i=0;i<MAX_ACTIVE_NOTES;i++) {
if ( voices[i].keydown == false && voices[i].live == true ) {
voices[i].live = false;
}
}
/*// 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
if ( index == 32 ) {
return;
}*/
for(int i=0;i<MAX_ACTIVE_NOTES;i++) {
if ( voices[i].keydown == false && voices[i].live == true ) {
voices[i].live = false;
}
}
index = index > 31 ? 31 : index;
unpackSysex(index);
currentProgram = index;
unpackSysex(index);
currentProgram = index;
lfo.reset(data + 137);
updateUI();
updateUI();
}
const String DexedAudioProcessor::getProgramName (int index) {
if ( index >= 32 )
index = 31;
index = 31;
return String(patchNames[index]);
}
@ -364,25 +364,25 @@ void DexedAudioProcessor::getStateInformation (MemoryBlock& destData) {
// 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
// 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) {
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
memcpy((void *)data, source, sizeInBytes);
updateUI();
memcpy((void *)data, source, sizeInBytes);
updateUI();
}
//==============================================================================
void DexedAudioProcessor::getCurrentProgramStateInformation (MemoryBlock& destData) {
destData.insert(data, 161, 0);
destData.insert(data, 161, 0);
}
void DexedAudioProcessor::setCurrentProgramStateInformation (const void* source, int sizeInBytes) {
memcpy((void *)data, source, sizeInBytes);
updateUI();
memcpy((void *)data, source, sizeInBytes);
updateUI();
}

@ -35,42 +35,42 @@ protected:
ComboBox *comboBox;
public:
String label;
String label;
Ctrl(String name);
Ctrl(String name);
void bind(Slider *s);
void bind(Button *b);
void bind(ComboBox *c);
void unbind();
virtual void setValuePlugin(float f) = 0;
virtual float getValuePlugin() = 0;
virtual String getValueDisplay() = 0;
virtual void setValuePlugin(float f) = 0;
virtual float getValuePlugin() = 0;
virtual String getValueDisplay() = 0;
virtual void updateComponent() = 0;
/**
* Index of this parameter
*/
int idx;
/**
* Index of this parameter
*/
int idx;
DexedAudioProcessor *parent;
};
// CtrlInt
class CtrlInt : public Ctrl {
int value;
int steps;
int add1;
int dxOffset;
int value;
int steps;
int add1;
int dxOffset;
public:
CtrlInt(String name, int steps, int offset = -1, bool starts1 = false);
CtrlInt(String name, int steps, int offset = -1, bool starts1 = false);
void setValuePlugin(float f);
float getValuePlugin();
void publishValue(int value);
void setValue(int value);
int getValue();
void setValue(int value);
int getValue();
String getValueDisplay();
void sliderValueChanged (Slider* moved);
void buttonClicked (Button* buttonThatWasClicked);
@ -80,8 +80,8 @@ public:
struct OperatorCtrl {
ScopedPointer<CtrlInt> egRate[4];
ScopedPointer<CtrlInt> egLevel[4];
ScopedPointer<CtrlInt> egRate[4];
ScopedPointer<CtrlInt> egLevel[4];
ScopedPointer<CtrlInt> level;
ScopedPointer<CtrlInt> opMode;
ScopedPointer<CtrlInt> coarse;

@ -47,7 +47,7 @@ DexedAudioProcessor::DexedAudioProcessor() {
}
DexedAudioProcessor::~DexedAudioProcessor() {
TRACE("Bye");
TRACE("Bye");
}
//==============================================================================
@ -356,13 +356,13 @@ bool DexedAudioProcessor::hasEditor() const {
}
void DexedAudioProcessor::updateUI() {
AudioProcessorEditor *editor = getActiveEditor();
if ( editor == NULL ) {
TRACE("no editor found");
return;
}
DexedAudioProcessorEditor *dexedEditor = (DexedAudioProcessorEditor *) editor;
dexedEditor->updateUI();
AudioProcessorEditor *editor = getActiveEditor();
if ( editor == NULL ) {
TRACE("no editor found");
return;
}
DexedAudioProcessorEditor *dexedEditor = (DexedAudioProcessorEditor *) editor;
dexedEditor->updateUI();
}
AudioProcessorEditor* DexedAudioProcessor::createEditor() {
@ -370,7 +370,7 @@ AudioProcessorEditor* DexedAudioProcessor::createEditor() {
}
void DexedAudioProcessor::log(const char *source, const char *fmt, ...) {
char output[4096];
char output[4096];
va_list argptr;
va_start(argptr, fmt);
vsnprintf(output, 4095, fmt, argptr);

Loading…
Cancel
Save