2
0
Fork 0

Enhanced MIDI CC

This commit is contained in:
George Reales 2021-05-16 18:15:11 +02:00
parent 839f492784
commit aa250fc799
2 changed files with 38 additions and 5 deletions

View file

@ -89,6 +89,7 @@ ObxdAudioProcessor::ObxdAudioProcessor()
}
apvtState.state = ValueTree (JucePlugin_Name);
initMidi();
}
ObxdAudioProcessor::~ObxdAudioProcessor()
@ -271,11 +272,19 @@ inline void ObxdAudioProcessor::processMidiPerSample (MidiBuffer::Iterator* iter
lastMovedController = midiMsg->getControllerNumber();
if (programs.currentProgramPtr->values[MIDILEARN] > 0.5f){
midiControlledParamSet = true;
bindings[lastMovedController] = lastUsedParameter;
//bindings[lastMovedController] = lastUsedParameter;
bindings.updateCC(lastMovedController, lastUsedParameter);
File midi_file = getDocumentFolder().getChildFile("Midi")
.getChildFile("Custom.xml");
bindings.saveFile(midi_file);
currentMidiPath = midi_file.getFullPathName();
setEngineParameterValue (MIDILEARN, 0, true);
lastMovedController = 0;
lastUsedParameter = 0;
midiControlledParamSet = false;
}
if (bindings[lastMovedController] > 0)
@ -373,7 +382,7 @@ void ObxdAudioProcessor::getStateInformation(MemoryBlock& destData)
xmlState.addChildElement(xprogs);
bindings.setXml(xmlState);
//bindings.setXml(xmlState);
copyXmlToBinary(xmlState, destData);
}
@ -430,7 +439,7 @@ void ObxdAudioProcessor::setStateInformation(const void* data, int sizeInBytes)
}
}
bindings.getXml(*xmlState);
//bindings.getXml(*xmlState);
#if ! DEMOVERSION
setCurrentProgram(xmlState->getIntAttribute(S("currentProgram"), 0));
@ -1184,3 +1193,27 @@ AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new ObxdAudioProcessor();
}
void ObxdAudioProcessor::initMidi(){
//Documents > Obxd > MIDI > Default.xml
File default_file = getDocumentFolder().getChildFile("Midi")
.getChildFile("Default.xml");
if (!default_file.exists()){
bindings.saveFile(default_file);
}
File midi_custom_file = getDocumentFolder().getChildFile("Midi")
.getChildFile("Custom.xml");
if (midi_custom_file.exists()) {
if (bindings.loadFile(midi_custom_file)){
currentMidiPath = midi_custom_file.getFullPathName();
} else {
if (bindings.loadFile(default_file)){
currentMidiPath = default_file.getFullPathName();
}
}
}
}

View file

@ -138,7 +138,7 @@ public:
//==============================================================================
void initAllParams();
void initMidi();
const String getInputChannelName (int channelIndex) const override; // WATCH OUT!
const String getOutputChannelName (int channelIndex) const override; // WATCH OUT!
bool isInputChannelStereoPair (int index) const override; // WATCH OUT!
@ -234,7 +234,7 @@ public:
File currentBankFile;
void saveBank();
String currentMidiPath;
String currentPreset;
File currentPresetFile;
void savePreset();