2
0
Fork 0

MIDI learn and clear

This commit is contained in:
George Reales 2020-07-16 10:14:56 +02:00
parent bc7dd1912d
commit 39fb65be68
3 changed files with 26 additions and 15 deletions

View file

@ -284,7 +284,7 @@ TooglableButton* ObxdAudioProcessorEditor::addButton (int x, int y, int w, int h
button->setButtonText (name); button->setButtonText (name);
button->setValue (filter.getPluginState().getParameter (filter.getEngineParameterId (parameter))->getValue(), button->setValue (filter.getPluginState().getParameter (filter.getEngineParameterId (parameter))->getValue(),
dontSendNotification); dontSendNotification);
button->addListener(this);
addAndMakeVisible (button); addAndMakeVisible (button);
return button; return button;
@ -429,6 +429,16 @@ void ObxdAudioProcessorEditor::buttonClicked (Button* b)
resultFromMenu (pos); resultFromMenu (pos);
} }
auto toggleButton = dynamic_cast<TooglableButton*> (b);
if (toggleButton == midiUnlearnButton){
if (midiUnlearnButton->toogled){
processor.getMidiMap().reset();
processor.getMidiMap().set_default();
}
}
} }
//============================================================================== //==============================================================================

View file

@ -229,14 +229,10 @@ inline void ObxdAudioProcessor::processMidiPerSample (MidiBuffer::Iterator* iter
{ {
lastMovedController = midiMsg->getControllerNumber(); lastMovedController = midiMsg->getControllerNumber();
if (programs.currentProgramPtr->values[MIDILEARN] > 0.5f) if (programs.currentProgramPtr->values[MIDILEARN] > 0.5f){
bindings[lastMovedController] = lastUsedParameter;
if (programs.currentProgramPtr->values[UNLEARN] > 0.5f)
{
midiControlledParamSet = true; midiControlledParamSet = true;
bindings[lastMovedController] = 0; bindings[lastMovedController] = lastUsedParameter;
setEngineParameterValue (UNLEARN, 0); setEngineParameterValue (MIDILEARN, 0, true);
lastMovedController = 0; lastMovedController = 0;
lastUsedParameter = 0; lastUsedParameter = 0;
midiControlledParamSet = false; midiControlledParamSet = false;
@ -760,7 +756,7 @@ int ObxdAudioProcessor::getParameterIndexFromId (String paramId)
return -1; return -1;
} }
void ObxdAudioProcessor::setEngineParameterValue (int index, float newValue) void ObxdAudioProcessor::setEngineParameterValue (int index, float newValue, bool notifyToHost)
{ {
if (! midiControlledParamSet || index == MIDILEARN || index == UNLEARN) if (! midiControlledParamSet || index == MIDILEARN || index == UNLEARN)
{ {
@ -768,8 +764,12 @@ void ObxdAudioProcessor::setEngineParameterValue (int index, float newValue)
} }
programs.currentProgramPtr->values[index] = newValue; programs.currentProgramPtr->values[index] = newValue;
apvtState.getParameter(getEngineParameterId(index))->setValue(newValue);
if (notifyToHost){
apvtState.getParameter(getEngineParameterId(index))->setValueNotifyingHost(newValue);
} else {
apvtState.getParameter(getEngineParameterId(index))->setValue(newValue);
}
switch (index) switch (index)
{ {

View file

@ -171,6 +171,7 @@ public:
bool restoreProgramSettings(const fxProgram* const prog); bool restoreProgramSettings(const fxProgram* const prog);
File getCurrentBankFile() const; File getCurrentBankFile() const;
MidiMap &getMidiMap(){ return bindings; }
//============================================================================== //==============================================================================
const ObxdBank& getPrograms() const { return programs; } const ObxdBank& getPrograms() const { return programs; }
@ -185,7 +186,7 @@ public:
//============================================================================== //==============================================================================
static String getEngineParameterId (size_t); static String getEngineParameterId (size_t);
int getParameterIndexFromId (String); int getParameterIndexFromId (String);
void setEngineParameterValue (int, float); void setEngineParameterValue (int, float, bool notifyToHost= false);
void parameterChanged (const String&, float) override; void parameterChanged (const String&, float) override;
AudioProcessorValueTreeState& getPluginState(); AudioProcessorValueTreeState& getPluginState();