2
0
Fork 0

Additional MIDI CC and fixes

This commit is contained in:
George Reales 2021-05-17 17:26:56 +02:00
parent 729890ef7e
commit 48849a96d8
4 changed files with 112 additions and 18 deletions

View file

@ -31,6 +31,8 @@ public:
int controllers[255]; int controllers[255];
int controllers_default[255]; int controllers_default[255];
std::map<String, int> mapping;
bool loaded = false; bool loaded = false;
MidiMap() MidiMap()
{ {
@ -39,243 +41,320 @@ public:
} }
void reset(){ void reset(){
for(int i = 0 ; i < 255;i++){ for(int i = 0 ; i < 255;i++){
controllers[i] = 0; controllers[i] = -1;
controllers_default[i] = 0; controllers_default[i] = -1;
} }
} }
void set_default(){ void set_default(){
int midicc = 71; int midicc = 71;
controllers[midicc] = controllers_default[midicc] = VOLUME; controllers[midicc] = controllers_default[midicc] = VOLUME;
mapping["VOLUME"]=VOLUME;
midicc = 15; midicc = 15;
controllers[midicc] = controllers_default[midicc] = VOICE_COUNT; controllers[midicc] = controllers_default[midicc] = VOICE_COUNT;
mapping["VOICE_COUNT"]=VOICE_COUNT;
midicc = 33; midicc = 33;
controllers[midicc] = controllers_default[midicc] = TUNE; controllers[midicc] = controllers_default[midicc] = TUNE;
mapping["TUNE"]=TUNE;
midicc = 17; midicc = 17;
controllers[midicc] = controllers_default[midicc] = OCTAVE; controllers[midicc] = controllers_default[midicc] = OCTAVE;
mapping["OCTAVE"]=OCTAVE;
midicc = 118; midicc = 118;
controllers[midicc] = controllers_default[midicc] = BENDRANGE; controllers[midicc] = controllers_default[midicc] = BENDRANGE;
mapping["BENDRANGE"]=BENDRANGE;
midicc = 34; midicc = 34;
controllers[midicc] = controllers_default[midicc] = BENDOSC2; controllers[midicc] = controllers_default[midicc] = BENDOSC2;
mapping["BENDOSC2"]=BENDOSC2;
midicc = 35; midicc = 35;
controllers[midicc] = controllers_default[midicc] = LEGATOMODE; controllers[midicc] = controllers_default[midicc] = LEGATOMODE;
mapping["LEGATOMODE"]=LEGATOMODE;
midicc = 75; midicc = 75;
controllers[midicc] = controllers_default[midicc] = BENDLFORATE; controllers[midicc] = controllers_default[midicc] = BENDLFORATE;
mapping["BENDLFORATE"]=BENDLFORATE;
midicc = 76; midicc = 76;
controllers[midicc] = controllers_default[midicc] = VFLTENV; controllers[midicc] = controllers_default[midicc] = VFLTENV;
mapping["VFLTENV"]=VFLTENV;
midicc = 20; midicc = 20;
controllers[midicc] = controllers_default[midicc] = VAMPENV; controllers[midicc] = controllers_default[midicc] = VAMPENV;
mapping["VAMPENV"]=VAMPENV;
midicc = 21; midicc = 21;
controllers[midicc] = controllers_default[midicc] = ASPLAYEDALLOCATION; controllers[midicc] = controllers_default[midicc] = ASPLAYEDALLOCATION;
mapping["ASPLAYEDALLOCATION"]=ASPLAYEDALLOCATION;
midicc = 23; midicc = 23;
controllers[midicc] = controllers_default[midicc] = PORTAMENTO; controllers[midicc] = controllers_default[midicc] = PORTAMENTO;
mapping["PORTAMENTO"]=PORTAMENTO;
midicc = 16; midicc = 16;
controllers[midicc] = controllers_default[midicc] = UNISON; controllers[midicc] = controllers_default[midicc] = UNISON;
mapping["UNISON"]=UNISON;
midicc = 24; midicc = 24;
controllers[midicc] = controllers_default[midicc] = UDET; controllers[midicc] = controllers_default[midicc] = UDET;
mapping["UDET"]=UDET;
midicc = 43; midicc = 43;
controllers[midicc] = controllers_default[midicc] = OSC2_DET; controllers[midicc] = controllers_default[midicc] = OSC2_DET;
mapping["OSC2_DET"]=OSC2_DET;
midicc = 19; midicc = 19;
controllers[midicc] = controllers_default[midicc] = LFOFREQ; controllers[midicc] = controllers_default[midicc] = LFOFREQ;
mapping["LFOFREQ"]=LFOFREQ;
midicc = 44; midicc = 44;
controllers[midicc] = controllers_default[midicc] = LFOSINWAVE; controllers[midicc] = controllers_default[midicc] = LFOSINWAVE;
mapping["LFOSINWAVE"]=LFOSINWAVE;
midicc = 45; midicc = 45;
controllers[midicc] = controllers_default[midicc] = LFOSQUAREWAVE; controllers[midicc] = controllers_default[midicc] = LFOSQUAREWAVE;
mapping["LFOSQUAREWAVE"]=LFOSQUAREWAVE;
midicc = 46; midicc = 46;
controllers[midicc] = controllers_default[midicc] = LFOSHWAVE; controllers[midicc] = controllers_default[midicc] = LFOSHWAVE;
mapping["LFOSHWAVE"]=LFOSHWAVE;
midicc = 22; midicc = 22;
controllers[midicc] = controllers_default[midicc] = LFO1AMT; controllers[midicc] = controllers_default[midicc] = LFO1AMT;
mapping["LFO1AMT"]=LFO1AMT;
midicc = 25; midicc = 25;
controllers[midicc] = controllers_default[midicc] = LFO2AMT; controllers[midicc] = controllers_default[midicc] = LFO2AMT;
mapping["LFO2AMT"]=LFO2AMT;
midicc = 47; midicc = 47;
controllers[midicc] = controllers_default[midicc] = LFOOSC1; controllers[midicc] = controllers_default[midicc] = LFOOSC1;
mapping["LFOOSC1"]=LFOOSC1;
midicc = 48; midicc = 48;
controllers[midicc] = controllers_default[midicc] = LFOOSC2; controllers[midicc] = controllers_default[midicc] = LFOOSC2;
mapping["LFOOSC2"]=LFOOSC2;
midicc = 49; midicc = 49;
controllers[midicc] = controllers_default[midicc] = LFOFILTER; controllers[midicc] = controllers_default[midicc] = LFOFILTER;
mapping["LFOFILTER"]=LFOFILTER;
midicc = 50; midicc = 50;
controllers[midicc] = controllers_default[midicc] = LFOPW1; controllers[midicc] = controllers_default[midicc] = LFOPW1;
mapping["LFOPW1"]=LFOPW1;
midicc = 51; midicc = 51;
controllers[midicc] = controllers_default[midicc] = LFOPW2; controllers[midicc] = controllers_default[midicc] = LFOPW2;
mapping["LFOPW2"]=LFOPW2;
midicc = 52; midicc = 52;
controllers[midicc] = controllers_default[midicc] = OSC2HS; controllers[midicc] = controllers_default[midicc] = OSC2HS;
mapping["OSC2HS"]=OSC2HS;
midicc = 53; midicc = 53;
controllers[midicc] = controllers_default[midicc] = XMOD; controllers[midicc] = controllers_default[midicc] = XMOD;
mapping["XMOD"]=XMOD;
midicc = 54; midicc = 54;
controllers[midicc] = controllers_default[midicc] = OSC1P; controllers[midicc] = controllers_default[midicc] = OSC1P;
mapping["OSC1P"]=OSC1P;
midicc = 55; midicc = 55;
controllers[midicc] = controllers_default[midicc] = OSC2P; controllers[midicc] = controllers_default[midicc] = OSC2P;
mapping["OSC2P"]=OSC2P;
midicc = 56; midicc = 56;
controllers[midicc] = controllers_default[midicc] = OSCQuantize; controllers[midicc] = controllers_default[midicc] = OSCQuantize;
mapping["OSCQuantize"]=OSCQuantize;
midicc = 57; midicc = 57;
controllers[midicc] = controllers_default[midicc] = OSC1Saw; controllers[midicc] = controllers_default[midicc] = OSC1Saw;
mapping["OSC1Saw"]=OSC1Saw;
midicc = 58; midicc = 58;
controllers[midicc] = controllers_default[midicc] = OSC1Pul; controllers[midicc] = controllers_default[midicc] = OSC1Pul;
mapping["OSC1Pul"]=OSC1Pul;
midicc = 59; midicc = 59;
controllers[midicc] = controllers_default[midicc] = OSC2Saw; controllers[midicc] = controllers_default[midicc] = OSC2Saw;
mapping["OSC2Saw"]=OSC2Saw;
midicc = 60; midicc = 60;
controllers[midicc] = controllers_default[midicc] = OSC2Pul; controllers[midicc] = controllers_default[midicc] = OSC2Pul;
mapping["OSC2Pul"]=OSC2Pul;
midicc = 61; midicc = 61;
controllers[midicc] = controllers_default[midicc] = PW; controllers[midicc] = controllers_default[midicc] = PW;
mapping["PW"]=PW;
midicc = 62; midicc = 62;
controllers[midicc] = controllers_default[midicc] = BRIGHTNESS; controllers[midicc] = controllers_default[midicc] = BRIGHTNESS;
mapping["BRIGHTNESS"]=BRIGHTNESS;
midicc = 63; midicc = 63;
controllers[midicc] = controllers_default[midicc] = ENVPITCH; controllers[midicc] = controllers_default[midicc] = ENVPITCH;
mapping["ENVPITCH"]=ENVPITCH;
midicc = 77; midicc = 77;
controllers[midicc] = controllers_default[midicc] = OSC1MIX; controllers[midicc] = controllers_default[midicc] = OSC1MIX;
mapping["OSC1MIX"]=OSC1MIX;
midicc = 78; midicc = 78;
controllers[midicc] = controllers_default[midicc] = OSC2MIX; controllers[midicc] = controllers_default[midicc] = OSC2MIX;
mapping["OSC2MIX"]=OSC2MIX;
midicc = 102; midicc = 102;
controllers[midicc] = controllers_default[midicc] = NOISEMIX; controllers[midicc] = controllers_default[midicc] = NOISEMIX;
mapping["NOISEMIX"]=NOISEMIX;
midicc = 103; midicc = 103;
controllers[midicc] = controllers_default[midicc] = FLT_KF; controllers[midicc] = controllers_default[midicc] = FLT_KF;
mapping["FLT_KF"]=FLT_KF;
midicc = 74; midicc = 74;
controllers[midicc] = controllers_default[midicc] = CUTOFF; controllers[midicc] = controllers_default[midicc] = CUTOFF;
mapping["CUTOFF"]=CUTOFF;
midicc = 42; midicc = 42;
controllers[midicc] = controllers_default[midicc] = RESONANCE; controllers[midicc] = controllers_default[midicc] = RESONANCE;
mapping["RESONANCE"]=RESONANCE;
midicc = 104; midicc = 104;
controllers[midicc] = controllers_default[midicc] = MULTIMODE; controllers[midicc] = controllers_default[midicc] = MULTIMODE;
mapping["MULTIMODE"]=MULTIMODE;
midicc = 18; midicc = 18;
controllers[midicc] = controllers_default[midicc] = FILTER_WARM; controllers[midicc] = controllers_default[midicc] = FILTER_WARM;
mapping["FILTER_WARM"]=FILTER_WARM;
midicc = 105; midicc = 105;
controllers[midicc] = controllers_default[midicc] = BANDPASS; controllers[midicc] = controllers_default[midicc] = BANDPASS;
mapping["BANDPASS"]=BANDPASS;
midicc = 106; midicc = 106;
controllers[midicc] = controllers_default[midicc] = FOURPOLE; controllers[midicc] = controllers_default[midicc] = FOURPOLE;
mapping["FOURPOLE"]=FOURPOLE;
midicc = 107; midicc = 107;
controllers[midicc] = controllers_default[midicc] = ENVELOPE_AMT; controllers[midicc] = controllers_default[midicc] = ENVELOPE_AMT;
mapping["ENVELOPE_AMT"]=ENVELOPE_AMT;
midicc = 73; midicc = 73;
controllers[midicc] = controllers_default[midicc] = LATK; controllers[midicc] = controllers_default[midicc] = LATK;
mapping["LATK"]=LATK;
midicc = 36; midicc = 36;
controllers[midicc] = controllers_default[midicc] = LDEC; controllers[midicc] = controllers_default[midicc] = LDEC;
mapping["LDEC"]=LDEC;
midicc = 37; midicc = 37;
controllers[midicc] = controllers_default[midicc] = LSUS; controllers[midicc] = controllers_default[midicc] = LSUS;
mapping["LSUS"]=LSUS;
midicc = 72; midicc = 72;
controllers[midicc] = controllers_default[midicc] = LREL; controllers[midicc] = controllers_default[midicc] = LREL;
mapping["LREL"]=LREL;
midicc = 38; midicc = 38;
controllers[midicc] = controllers_default[midicc] = FATK; controllers[midicc] = controllers_default[midicc] = FATK;
mapping["FATK"]=FATK;
midicc = 39; midicc = 39;
controllers[midicc] = controllers_default[midicc] = FDEC; controllers[midicc] = controllers_default[midicc] = FDEC;
mapping["FDEC"]=FDEC;
midicc = 40; midicc = 40;
controllers[midicc] = controllers_default[midicc] = FSUS; controllers[midicc] = controllers_default[midicc] = FSUS;
mapping["FSUS"]=FSUS;
midicc = 41; midicc = 41;
controllers[midicc] = controllers_default[midicc] = FREL; controllers[midicc] = controllers_default[midicc] = FREL;
mapping["FREL"]=FREL;
midicc = 108; midicc = 108;
controllers[midicc] = controllers_default[midicc] = ENVDER; controllers[midicc] = controllers_default[midicc] = ENVDER;
mapping["ENVDER"]=ENVDER;
midicc = 109; midicc = 109;
controllers[midicc] = controllers_default[midicc] = FILTERDER; controllers[midicc] = controllers_default[midicc] = FILTERDER;
mapping["FILTERDER"]=FILTERDER;
midicc = 110; midicc = 110;
controllers[midicc] = controllers_default[midicc] = PORTADER; controllers[midicc] = controllers_default[midicc] = PORTADER;
mapping["PORTADER"]=PORTADER;
midicc = 81; midicc = 81;
controllers[midicc] = controllers_default[midicc] = PAN1; controllers[midicc] = controllers_default[midicc] = PAN1;
mapping["PAN1"]=PAN1;
midicc = 82; midicc = 82;
controllers[midicc] = controllers_default[midicc] = PAN2; controllers[midicc] = controllers_default[midicc] = PAN2;
mapping["PAN2"]=PAN2;
midicc = 83; midicc = 83;
controllers[midicc] = controllers_default[midicc] = PAN3; controllers[midicc] = controllers_default[midicc] = PAN3;
mapping["PAN3"]=PAN3;
midicc = 84; midicc = 84;
controllers[midicc] = controllers_default[midicc] = PAN4; controllers[midicc] = controllers_default[midicc] = PAN4;
mapping["PAN4"]=PAN4;
midicc = 85; midicc = 85;
controllers[midicc] = controllers_default[midicc] = PAN5; controllers[midicc] = controllers_default[midicc] = PAN5;
mapping["PAN5"]=PAN5;
midicc = 86; midicc = 86;
controllers[midicc] = controllers_default[midicc] = PAN6; controllers[midicc] = controllers_default[midicc] = PAN6;
mapping["PAN6"]=PAN6;
midicc = 87; midicc = 87;
controllers[midicc] = controllers_default[midicc] = PAN7; controllers[midicc] = controllers_default[midicc] = PAN7;
mapping["PAN7"]=PAN7;
midicc = 88; midicc = 88;
controllers[midicc] = controllers_default[midicc] = PAN8; controllers[midicc] = controllers_default[midicc] = PAN8;
mapping["PAN8"]=PAN8;
midicc = 111; midicc = 111;
controllers[midicc] = controllers_default[midicc] = ECONOMY_MODE; controllers[midicc] = controllers_default[midicc] = ECONOMY_MODE;
mapping["ECONOMY_MODE"]=ECONOMY_MODE;
//midicc = 112; //midicc = 112;
//controllers[midicc] = controllers_default[midicc] = LFO_SYNC; //controllers[midicc] = controllers_default[midicc] = LFO_SYNC;
midicc = 113; midicc = 113;
controllers[midicc] = controllers_default[midicc] = PW_ENV; controllers[midicc] = controllers_default[midicc] = PW_ENV;
mapping["PW_ENV"]=PW_ENV;
midicc = 114; midicc = 114;
controllers[midicc] = controllers_default[midicc] = PW_ENV_BOTH; controllers[midicc] = controllers_default[midicc] = PW_ENV_BOTH;
mapping["PW_ENV_BOTH"]=PW_ENV_BOTH;
midicc = 115; midicc = 115;
controllers[midicc] = controllers_default[midicc] = ENV_PITCH_BOTH; controllers[midicc] = controllers_default[midicc] = ENV_PITCH_BOTH;
mapping["ENV_PITCH_BOTH"]=ENV_PITCH_BOTH;
midicc = 116; midicc = 116;
controllers[midicc] = controllers_default[midicc] = FENV_INVERT; controllers[midicc] = controllers_default[midicc] = FENV_INVERT;
mapping["FENV_INVERT"]=FENV_INVERT;
midicc = 117; midicc = 117;
controllers[midicc] = controllers_default[midicc] = PW_OSC2_OFS; controllers[midicc] = controllers_default[midicc] = PW_OSC2_OFS;
mapping["PW_OSC2_OFS"]=PW_OSC2_OFS;
midicc = 118; midicc = 118;
controllers[midicc] = controllers_default[midicc] = LEVEL_DIF; controllers[midicc] = controllers_default[midicc] = LEVEL_DIF;
mapping["LEVEL_DIF"]=LEVEL_DIF;
midicc = 119; midicc = 119;
controllers[midicc] = controllers_default[midicc] = SELF_OSC_PUSH; controllers[midicc] = controllers_default[midicc] = SELF_OSC_PUSH;
mapping["SELF_OSC_PUSH"]=SELF_OSC_PUSH;
} }
@ -290,19 +369,31 @@ public:
void setXml( XmlElement &xml){ void setXml( XmlElement &xml){
for (int i = 0; i < 255; ++i) for (int i = 0; i < 255; ++i)
{ {
xml.setAttribute("Val_" + String(i), controllers[i]); if (controllers[i]!= -1){
xml.setAttribute("MIDI_" +String(i), getTag(controllers[i]));
}
} }
} }
String getTag(int paraId){
for (std::map<String, int>::iterator it = this->mapping.begin(); it != this->mapping.end(); it ++){
if (paraId == it->second){
return it->first;
}
}
return "undefine";
}
int getParaId(String tagName){
return mapping[tagName];
}
void getXml(XmlElement &xml){ void getXml(XmlElement &xml){
for (int i = 0; i < 255; ++i) for (int i = 0; i < 255; ++i)
{ {
int tmp = xml.getIntAttribute("Val_" + String(i), controllers_default[i]); String tmp = xml.getStringAttribute("MIDI_" + String(i), "undefine");
if (tmp == 0){ if (tmp != "undefine"){
tmp = controllers_default[i]; controllers[i] = getParaId(tmp);
} }
controllers[i] = tmp;
} }
// Backward keys // Backward keys
@ -316,7 +407,6 @@ public:
} }
} }
bool loadFile(File& xml){ bool loadFile(File& xml){
reset(); reset();
set_default(); set_default();
@ -331,11 +421,11 @@ public:
void updateCC(int idx_para, int midiCC) { void updateCC(int idx_para, int midiCC) {
for (int i =0; i < 255; i++) { for (int i =0; i < 255; i++) {
if (controllers[i] == midiCC){ if (controllers[i] == idx_para){
controllers[i] = 0; controllers[i] = -1;
} }
} }
controllers[idx_para] = midiCC; controllers[midiCC] = idx_para;
} }
void saveFile(File& xml){ void saveFile(File& xml){

View file

@ -931,6 +931,9 @@ void ObxdAudioProcessorEditor::filesDropped(const StringArray& files, int x, int
processor.setCurrentProgram(i++); processor.setCurrentProgram(i++);
processor.loadPreset(file); processor.loadPreset(file);
} }
if (i >=processor.getNumPrograms()){
i = 0;
}
} }
processor.sendChangeMessage(); processor.sendChangeMessage();
createMenu(); createMenu();

View file

@ -273,7 +273,7 @@ inline void ObxdAudioProcessor::processMidiPerSample (MidiBuffer::Iterator* iter
if (programs.currentProgramPtr->values[MIDILEARN] > 0.5f){ if (programs.currentProgramPtr->values[MIDILEARN] > 0.5f){
midiControlledParamSet = true; midiControlledParamSet = true;
//bindings[lastMovedController] = lastUsedParameter; //bindings[lastMovedController] = lastUsedParameter;
bindings.updateCC(lastMovedController, lastUsedParameter); bindings.updateCC(lastUsedParameter, lastMovedController);
File midi_file = getDocumentFolder().getChildFile("Midi") File midi_file = getDocumentFolder().getChildFile("Midi")
.getChildFile("Custom.xml"); .getChildFile("Custom.xml");
bindings.saveFile(midi_file); bindings.saveFile(midi_file);
@ -605,7 +605,7 @@ bool ObxdAudioProcessor::saveFXBFile(const File& fxbFile) {
return true; return true;
} }
bool ObxdAudioProcessor::loadFromFXBFile(const File& fxbFile) bool ObxdAudioProcessor::loadFromFXBFile(const File& fxbFile, bool changeProgram)
{ {
MemoryBlock mb; MemoryBlock mb;
if (! fxbFile.loadFileAsData(mb)) if (! fxbFile.loadFileAsData(mb))
@ -680,7 +680,8 @@ bool ObxdAudioProcessor::loadFromFXBFile(const File& fxbFile)
return false; return false;
setStateInformation(cset->chunk, fxbSwap (cset->chunkSize)); setStateInformation(cset->chunk, fxbSwap (cset->chunkSize));
setCurrentProgram(0); // Set to first preset position if (changeProgram)
setCurrentProgram(0); // Set to first preset position
} }
else if (compareMagic (set->fxMagic, "FPCh")) else if (compareMagic (set->fxMagic, "FPCh"))
{ {

View file

@ -175,7 +175,7 @@ public:
void newPreset(const String &name); void newPreset(const String &name);
void deletePreset(); void deletePreset();
bool loadFromFXBFile(const File& fxbFile); bool loadFromFXBFile(const File& fxbFile, bool changeProgram=true);
bool saveFXBFile(const File& fxbFile); bool saveFXBFile(const File& fxbFile);
bool saveFXPFile(const File& fxpFile); bool saveFXPFile(const File& fxpFile);
bool saveBank(const File& fxbFile); bool saveBank(const File& fxbFile);