2
0
Fork 0
OB-Xd/Source/Engine/midiMap.h

442 lines
14 KiB
C
Raw Normal View History

2017-01-23 10:15:08 +00:00
/*
==============================================================================
This file is part of Obxd synthesizer.
2020-07-13 09:19:34 +00:00
Copyright © 2013-2014 Filatov Vadim
2017-01-23 10:15:08 +00:00
Contact author via email :
justdat_@_e1.ru
This file may be licensed under the terms of of the
GNU General Public License Version 2 (the ``GPL'').
Software distributed under the License is distributed
on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
express or implied. See the GPL for the specific language
governing rights and limitations.
You should have received a copy of the GPL along with this
program. If not, go to http://www.gnu.org/licenses/gpl.html
or write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
==============================================================================
*/
#pragma once
#include "SynthEngine.h"
2020-07-13 09:19:34 +00:00
#include "ParamsEnum.h"
#include "../JuceLibraryCode/JuceHeader.h"
2017-01-23 10:15:08 +00:00
class MidiMap
{
public:
int controllers[255];
2020-07-13 09:19:34 +00:00
int controllers_default[255];
2021-05-17 15:26:56 +00:00
std::map<String, int> mapping;
2020-07-13 09:19:34 +00:00
bool loaded = false;
2017-01-23 10:15:08 +00:00
MidiMap()
{
2020-07-13 09:19:34 +00:00
reset();
set_default();
2017-01-23 10:15:08 +00:00
}
2020-07-13 09:19:34 +00:00
void reset(){
for(int i = 0 ; i < 255;i++){
2021-05-17 15:26:56 +00:00
controllers[i] = -1;
controllers_default[i] = -1;
2020-07-13 09:19:34 +00:00
}
}
void set_default(){
int midicc = 71;
controllers[midicc] = controllers_default[midicc] = VOLUME;
2021-05-17 15:26:56 +00:00
mapping["VOLUME"]=VOLUME;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 15;
2020-07-13 09:19:34 +00:00
controllers[midicc] = controllers_default[midicc] = VOICE_COUNT;
2021-05-17 15:26:56 +00:00
mapping["VOICE_COUNT"]=VOICE_COUNT;
2020-07-13 09:19:34 +00:00
midicc = 33;
controllers[midicc] = controllers_default[midicc] = TUNE;
2021-05-17 15:26:56 +00:00
mapping["TUNE"]=TUNE;
2020-07-13 09:19:34 +00:00
midicc = 17;
controllers[midicc] = controllers_default[midicc] = OCTAVE;
2021-05-17 15:26:56 +00:00
mapping["OCTAVE"]=OCTAVE;
2020-07-13 09:19:34 +00:00
midicc = 118;
controllers[midicc] = controllers_default[midicc] = BENDRANGE;
2021-05-17 15:26:56 +00:00
mapping["BENDRANGE"]=BENDRANGE;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 34;
controllers[midicc] = controllers_default[midicc] = BENDOSC2;
2021-05-17 15:26:56 +00:00
mapping["BENDOSC2"]=BENDOSC2;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 35;
controllers[midicc] = controllers_default[midicc] = LEGATOMODE;
2021-05-17 15:26:56 +00:00
mapping["LEGATOMODE"]=LEGATOMODE;
2020-07-13 09:19:34 +00:00
2020-07-25 08:21:09 +00:00
midicc = 75;
2020-07-14 06:57:34 +00:00
controllers[midicc] = controllers_default[midicc] = BENDLFORATE;
2021-05-17 15:26:56 +00:00
mapping["BENDLFORATE"]=BENDLFORATE;
2020-07-13 09:19:34 +00:00
2020-07-25 08:21:09 +00:00
midicc = 76;
2020-07-14 06:57:34 +00:00
controllers[midicc] = controllers_default[midicc] = VFLTENV;
2021-05-17 15:26:56 +00:00
mapping["VFLTENV"]=VFLTENV;
2020-07-13 09:19:34 +00:00
2020-07-15 07:24:24 +00:00
midicc = 20;
2020-07-14 06:57:34 +00:00
controllers[midicc] = controllers_default[midicc] = VAMPENV;
2021-05-17 15:26:56 +00:00
mapping["VAMPENV"]=VAMPENV;
2020-07-13 09:19:34 +00:00
2020-07-15 07:24:24 +00:00
midicc = 21;
2020-07-14 06:57:34 +00:00
controllers[midicc] = controllers_default[midicc] = ASPLAYEDALLOCATION;
2021-05-17 15:26:56 +00:00
mapping["ASPLAYEDALLOCATION"]=ASPLAYEDALLOCATION;
2020-07-13 09:19:34 +00:00
2020-07-15 07:24:24 +00:00
midicc = 23;
2020-07-14 06:57:34 +00:00
controllers[midicc] = controllers_default[midicc] = PORTAMENTO;
2021-05-17 15:26:56 +00:00
mapping["PORTAMENTO"]=PORTAMENTO;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 16;
controllers[midicc] = controllers_default[midicc] = UNISON;
2021-05-17 15:26:56 +00:00
mapping["UNISON"]=UNISON;
2020-07-13 09:19:34 +00:00
2020-07-15 07:24:24 +00:00
midicc = 24;
2020-07-14 06:57:34 +00:00
controllers[midicc] = controllers_default[midicc] = UDET;
2021-05-17 15:26:56 +00:00
mapping["UDET"]=UDET;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 43;
controllers[midicc] = controllers_default[midicc] = OSC2_DET;
2021-05-17 15:26:56 +00:00
mapping["OSC2_DET"]=OSC2_DET;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 19;
controllers[midicc] = controllers_default[midicc] = LFOFREQ;
2021-05-17 15:26:56 +00:00
mapping["LFOFREQ"]=LFOFREQ;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 44;
controllers[midicc] = controllers_default[midicc] = LFOSINWAVE;
2021-05-17 15:26:56 +00:00
mapping["LFOSINWAVE"]=LFOSINWAVE;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 45;
controllers[midicc] = controllers_default[midicc] = LFOSQUAREWAVE;
2021-05-17 15:26:56 +00:00
mapping["LFOSQUAREWAVE"]=LFOSQUAREWAVE;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 46;
controllers[midicc] = controllers_default[midicc] = LFOSHWAVE;
2021-05-17 15:26:56 +00:00
mapping["LFOSHWAVE"]=LFOSHWAVE;
2020-07-13 09:19:34 +00:00
midicc = 22;
controllers[midicc] = controllers_default[midicc] = LFO1AMT;
2021-05-17 15:26:56 +00:00
mapping["LFO1AMT"]=LFO1AMT;
2020-07-13 09:19:34 +00:00
midicc = 25;
controllers[midicc] = controllers_default[midicc] = LFO2AMT;
2021-05-17 15:26:56 +00:00
mapping["LFO2AMT"]=LFO2AMT;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 47;
controllers[midicc] = controllers_default[midicc] = LFOOSC1;
2021-05-17 15:26:56 +00:00
mapping["LFOOSC1"]=LFOOSC1;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 48;
controllers[midicc] = controllers_default[midicc] = LFOOSC2;
2021-05-17 15:26:56 +00:00
mapping["LFOOSC2"]=LFOOSC2;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 49;
controllers[midicc] = controllers_default[midicc] = LFOFILTER;
2021-05-17 15:26:56 +00:00
mapping["LFOFILTER"]=LFOFILTER;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 50;
controllers[midicc] = controllers_default[midicc] = LFOPW1;
2021-05-17 15:26:56 +00:00
mapping["LFOPW1"]=LFOPW1;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 51;
controllers[midicc] = controllers_default[midicc] = LFOPW2;
2021-05-17 15:26:56 +00:00
mapping["LFOPW2"]=LFOPW2;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 52;
controllers[midicc] = controllers_default[midicc] = OSC2HS;
2021-05-17 15:26:56 +00:00
mapping["OSC2HS"]=OSC2HS;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 53;
controllers[midicc] = controllers_default[midicc] = XMOD;
2021-05-17 15:26:56 +00:00
mapping["XMOD"]=XMOD;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 54;
controllers[midicc] = controllers_default[midicc] = OSC1P;
2021-05-17 15:26:56 +00:00
mapping["OSC1P"]=OSC1P;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 55;
controllers[midicc] = controllers_default[midicc] = OSC2P;
2021-05-17 15:26:56 +00:00
mapping["OSC2P"]=OSC2P;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 56;
controllers[midicc] = controllers_default[midicc] = OSCQuantize;
2021-05-17 15:26:56 +00:00
mapping["OSCQuantize"]=OSCQuantize;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 57;
controllers[midicc] = controllers_default[midicc] = OSC1Saw;
2021-05-17 15:26:56 +00:00
mapping["OSC1Saw"]=OSC1Saw;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 58;
controllers[midicc] = controllers_default[midicc] = OSC1Pul;
2021-05-17 15:26:56 +00:00
mapping["OSC1Pul"]=OSC1Pul;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 59;
controllers[midicc] = controllers_default[midicc] = OSC2Saw;
2021-05-17 15:26:56 +00:00
mapping["OSC2Saw"]=OSC2Saw;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 60;
controllers[midicc] = controllers_default[midicc] = OSC2Pul;
2021-05-17 15:26:56 +00:00
mapping["OSC2Pul"]=OSC2Pul;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 61;
controllers[midicc] = controllers_default[midicc] = PW;
2021-05-17 15:26:56 +00:00
mapping["PW"]=PW;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 62;
controllers[midicc] = controllers_default[midicc] = BRIGHTNESS;
2021-05-17 15:26:56 +00:00
mapping["BRIGHTNESS"]=BRIGHTNESS;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 63;
controllers[midicc] = controllers_default[midicc] = ENVPITCH;
2021-05-17 15:26:56 +00:00
mapping["ENVPITCH"]=ENVPITCH;
2020-07-13 09:19:34 +00:00
midicc = 77;
2020-07-14 06:57:34 +00:00
controllers[midicc] = controllers_default[midicc] = OSC1MIX;
2021-05-17 15:26:56 +00:00
mapping["OSC1MIX"]=OSC1MIX;
midicc = 78;
2020-07-14 06:57:34 +00:00
controllers[midicc] = controllers_default[midicc] = OSC2MIX;
2021-05-17 15:26:56 +00:00
mapping["OSC2MIX"]=OSC2MIX;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 102;
controllers[midicc] = controllers_default[midicc] = NOISEMIX;
2021-05-17 15:26:56 +00:00
mapping["NOISEMIX"]=NOISEMIX;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 103;
controllers[midicc] = controllers_default[midicc] = FLT_KF;
2021-05-17 15:26:56 +00:00
mapping["FLT_KF"]=FLT_KF;
2020-07-13 09:19:34 +00:00
midicc = 74;
controllers[midicc] = controllers_default[midicc] = CUTOFF;
2021-05-17 15:26:56 +00:00
mapping["CUTOFF"]=CUTOFF;
2020-07-13 09:19:34 +00:00
midicc = 42;
controllers[midicc] = controllers_default[midicc] = RESONANCE;
2021-05-17 15:26:56 +00:00
mapping["RESONANCE"]=RESONANCE;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 104;
controllers[midicc] = controllers_default[midicc] = MULTIMODE;
2021-05-17 15:26:56 +00:00
mapping["MULTIMODE"]=MULTIMODE;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 18;
2020-07-13 09:19:34 +00:00
controllers[midicc] = controllers_default[midicc] = FILTER_WARM;
2021-05-17 15:26:56 +00:00
mapping["FILTER_WARM"]=FILTER_WARM;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 105;
controllers[midicc] = controllers_default[midicc] = BANDPASS;
2021-05-17 15:26:56 +00:00
mapping["BANDPASS"]=BANDPASS;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 106;
controllers[midicc] = controllers_default[midicc] = FOURPOLE;
2021-05-17 15:26:56 +00:00
mapping["FOURPOLE"]=FOURPOLE;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 107;
controllers[midicc] = controllers_default[midicc] = ENVELOPE_AMT;
2021-05-17 15:26:56 +00:00
mapping["ENVELOPE_AMT"]=ENVELOPE_AMT;
2020-07-13 09:19:34 +00:00
midicc = 73;
controllers[midicc] = controllers_default[midicc] = LATK;
2021-05-17 15:26:56 +00:00
mapping["LATK"]=LATK;
2020-07-13 09:19:34 +00:00
midicc = 36;
controllers[midicc] = controllers_default[midicc] = LDEC;
2021-05-17 15:26:56 +00:00
mapping["LDEC"]=LDEC;
2020-07-13 09:19:34 +00:00
midicc = 37;
controllers[midicc] = controllers_default[midicc] = LSUS;
2021-05-17 15:26:56 +00:00
mapping["LSUS"]=LSUS;
2020-07-13 09:19:34 +00:00
midicc = 72;
controllers[midicc] = controllers_default[midicc] = LREL;
2021-05-17 15:26:56 +00:00
mapping["LREL"]=LREL;
2020-07-13 09:19:34 +00:00
midicc = 38;
controllers[midicc] = controllers_default[midicc] = FATK;
2021-05-17 15:26:56 +00:00
mapping["FATK"]=FATK;
2020-07-13 09:19:34 +00:00
midicc = 39;
controllers[midicc] = controllers_default[midicc] = FDEC;
2021-05-17 15:26:56 +00:00
mapping["FDEC"]=FDEC;
2020-07-13 09:19:34 +00:00
midicc = 40;
controllers[midicc] = controllers_default[midicc] = FSUS;
2021-05-17 15:26:56 +00:00
mapping["FSUS"]=FSUS;
2020-07-13 09:19:34 +00:00
midicc = 41;
controllers[midicc] = controllers_default[midicc] = FREL;
2021-05-17 15:26:56 +00:00
mapping["FREL"]=FREL;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 108;
controllers[midicc] = controllers_default[midicc] = ENVDER;
2021-05-17 15:26:56 +00:00
mapping["ENVDER"]=ENVDER;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 109;
controllers[midicc] = controllers_default[midicc] = FILTERDER;
2021-05-17 15:26:56 +00:00
mapping["FILTERDER"]=FILTERDER;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 110;
controllers[midicc] = controllers_default[midicc] = PORTADER;
2021-05-17 15:26:56 +00:00
mapping["PORTADER"]=PORTADER;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 81;
controllers[midicc] = controllers_default[midicc] = PAN1;
2021-05-17 15:26:56 +00:00
mapping["PAN1"]=PAN1;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 82;
controllers[midicc] = controllers_default[midicc] = PAN2;
2021-05-17 15:26:56 +00:00
mapping["PAN2"]=PAN2;
2020-07-13 09:19:34 +00:00
midicc = 83;
controllers[midicc] = controllers_default[midicc] = PAN3;
2021-05-17 15:26:56 +00:00
mapping["PAN3"]=PAN3;
2020-07-13 09:19:34 +00:00
midicc = 84;
controllers[midicc] = controllers_default[midicc] = PAN4;
2021-05-17 15:26:56 +00:00
mapping["PAN4"]=PAN4;
2020-07-13 09:19:34 +00:00
midicc = 85;
controllers[midicc] = controllers_default[midicc] = PAN5;
2021-05-17 15:26:56 +00:00
mapping["PAN5"]=PAN5;
2020-07-13 09:19:34 +00:00
midicc = 86;
controllers[midicc] = controllers_default[midicc] = PAN6;
2021-05-17 15:26:56 +00:00
mapping["PAN6"]=PAN6;
2020-07-13 09:19:34 +00:00
midicc = 87;
controllers[midicc] = controllers_default[midicc] = PAN7;
2021-05-17 15:26:56 +00:00
mapping["PAN7"]=PAN7;
2020-07-13 09:19:34 +00:00
midicc = 88;
controllers[midicc] = controllers_default[midicc] = PAN8;
2021-05-17 15:26:56 +00:00
mapping["PAN8"]=PAN8;
2020-07-13 09:19:34 +00:00
2020-07-19 09:59:31 +00:00
midicc = 111;
controllers[midicc] = controllers_default[midicc] = ECONOMY_MODE;
2021-05-17 15:26:56 +00:00
mapping["ECONOMY_MODE"]=ECONOMY_MODE;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
//midicc = 112;
2020-07-13 09:19:34 +00:00
//controllers[midicc] = controllers_default[midicc] = LFO_SYNC;
2020-07-14 06:57:34 +00:00
midicc = 113;
controllers[midicc] = controllers_default[midicc] = PW_ENV;
2021-05-17 15:26:56 +00:00
mapping["PW_ENV"]=PW_ENV;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 114;
controllers[midicc] = controllers_default[midicc] = PW_ENV_BOTH;
2021-05-17 15:26:56 +00:00
mapping["PW_ENV_BOTH"]=PW_ENV_BOTH;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 115;
controllers[midicc] = controllers_default[midicc] = ENV_PITCH_BOTH;
2021-05-17 15:26:56 +00:00
mapping["ENV_PITCH_BOTH"]=ENV_PITCH_BOTH;
2020-07-13 09:19:34 +00:00
2020-07-19 09:59:31 +00:00
midicc = 116;
controllers[midicc] = controllers_default[midicc] = FENV_INVERT;
2021-05-17 15:26:56 +00:00
mapping["FENV_INVERT"]=FENV_INVERT;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 117;
controllers[midicc] = controllers_default[midicc] = PW_OSC2_OFS;
2021-05-17 15:26:56 +00:00
mapping["PW_OSC2_OFS"]=PW_OSC2_OFS;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 118;
controllers[midicc] = controllers_default[midicc] = LEVEL_DIF;
2021-05-17 15:26:56 +00:00
mapping["LEVEL_DIF"]=LEVEL_DIF;
2020-07-13 09:19:34 +00:00
2020-07-14 06:57:34 +00:00
midicc = 119;
controllers[midicc] = controllers_default[midicc] = SELF_OSC_PUSH;
2021-05-17 15:26:56 +00:00
mapping["SELF_OSC_PUSH"]=SELF_OSC_PUSH;
2020-07-13 09:19:34 +00:00
}
int& operator[](int index)
{
if (index >= 255) {
exit(0);
}
return controllers[index];
}
void setXml( XmlElement &xml){
for (int i = 0; i < 255; ++i)
{
2021-05-17 15:26:56 +00:00
if (controllers[i]!= -1){
xml.setAttribute("MIDI_" +String(i), getTag(controllers[i]));
}
2020-07-13 09:19:34 +00:00
}
}
2021-05-17 15:26:56 +00:00
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];
}
2020-07-13 09:19:34 +00:00
void getXml(XmlElement &xml){
for (int i = 0; i < 255; ++i)
{
2021-05-17 15:26:56 +00:00
String tmp = xml.getStringAttribute("MIDI_" + String(i), "undefine");
if (tmp != "undefine"){
controllers[i] = getParaId(tmp);
2020-07-13 09:19:34 +00:00
}
}
2020-08-06 20:03:54 +00:00
// Backward keys
if (controllers[100] > 0) {
controllers[77] = controllers_default[77];
controllers[100] = 0;
}
if ( controllers[101] > 0) {
controllers[78] = controllers_default[78];
controllers[101] = 0;
}
2020-07-13 09:19:34 +00:00
}
2020-08-06 20:03:54 +00:00
2021-05-16 16:39:23 +00:00
bool loadFile(File& xml){
reset();
set_default();
if (xml.existsAsFile()){
XmlDocument xmlDoc (xml);
this->getXml(*xmlDoc.getDocumentElement());
return true;
}
return false;
}
void updateCC(int idx_para, int midiCC) {
for (int i =0; i < 255; i++) {
2021-05-17 15:26:56 +00:00
if (controllers[i] == idx_para){
controllers[i] = -1;
2021-05-16 16:39:23 +00:00
}
}
2021-05-17 15:26:56 +00:00
controllers[midiCC] = idx_para;
2021-05-16 16:39:23 +00:00
}
void saveFile(File& xml){
XmlElement ele("Data");
this->setXml(ele);
ele.writeToFile(xml, String());
}
void clean(){
reset();
}
2020-07-13 09:19:34 +00:00
};