diff --git a/Source/Gui/ButtonList.h b/Source/Gui/ButtonList.h index 4e0fb5f..0f8fcdd 100755 --- a/Source/Gui/ButtonList.h +++ b/Source/Gui/ButtonList.h @@ -40,19 +40,29 @@ public: public: class ButtonListAttachment : public juce::AudioProcessorValueTreeState::ComboBoxAttachment { + RangedAudioParameter* parameter = nullptr; + ButtonList* buttonListToControl = nullptr; public: ButtonListAttachment (juce::AudioProcessorValueTreeState& stateToControl, const juce::String& parameterID, - ButtonList& buttonListToControl) : AudioProcessorValueTreeState::ComboBoxAttachment (stateToControl, parameterID, buttonListToControl) + ButtonList& buttonListToControl) : AudioProcessorValueTreeState::ComboBoxAttachment (stateToControl, parameterID, buttonListToControl), buttonListToControl(&buttonListToControl) { - buttonListToControl.setParameter (stateToControl.getParameter (parameterID)); + parameter = stateToControl.getParameter (parameterID); + buttonListToControl.setParameter (parameter); } - + /* ButtonListAttachment (juce::AudioProcessorValueTreeState& stateToControl, const juce::String& parameterID, ComboBox& buttonListToControl) : AudioProcessorValueTreeState::ComboBoxAttachment (stateToControl, parameterID, buttonListToControl) { } + */ + void updateToSlider(){ + float val = parameter->getValue(); + buttonListToControl->setValue(val, NotificationType::dontSendNotification); + //buttonListToControl->setValue(parameter->convertFrom0to1(val0to1), NotificationType::dontSendNotification); + buttonListToControl->setValue(val, NotificationType::dontSendNotification); + } virtual ~ButtonListAttachment() = default; }; diff --git a/Source/Gui/Knob.h b/Source/Gui/Knob.h index a44c018..6d4663f 100755 --- a/Source/Gui/Knob.h +++ b/Source/Gui/Knob.h @@ -46,24 +46,35 @@ public: public: class KnobAttachment : public juce::AudioProcessorValueTreeState::SliderAttachment { + RangedAudioParameter* parameter = nullptr; + Knob* sliderToControl = nullptr; public: KnobAttachment (juce::AudioProcessorValueTreeState& stateToControl, const juce::String& parameterID, - Knob& sliderToControl) : AudioProcessorValueTreeState::SliderAttachment (stateToControl, parameterID, sliderToControl) + Knob& sliderToControl) : AudioProcessorValueTreeState::SliderAttachment (stateToControl, parameterID, sliderToControl), sliderToControl(&sliderToControl) { - sliderToControl.setParameter (stateToControl.getParameter (parameterID)); + parameter = stateToControl.getParameter (parameterID); + sliderToControl.setParameter (parameter); } - KnobAttachment (juce::AudioProcessorValueTreeState& stateToControl, + + /*KnobAttachment (juce::AudioProcessorValueTreeState& stateToControl, const juce::String& parameterID, Slider& sliderToControl) : AudioProcessorValueTreeState::SliderAttachment (stateToControl, parameterID, sliderToControl) { + }*/ + + void updateToSlider(){ + float val = parameter->getValue(); + //sliderToControl->setValue(parameter->convertFrom0to1(val0to1)); + sliderToControl->setValue(val, NotificationType::dontSendNotification); + DBG(" Slider: " << sliderToControl->getName() << " " << sliderToControl->getValue() << " Parameter: "<< " " << parameter->getValue()); } virtual ~KnobAttachment() = default; }; - void setParameter (const AudioProcessorParameter* p) + void setParameter (AudioProcessorParameter* p) { if (parameter == p) return; @@ -84,5 +95,5 @@ private: Image kni; int fh, numFr; int w2, h2; - const AudioProcessorParameter* parameter {nullptr}; + AudioProcessorParameter* parameter {nullptr}; }; diff --git a/Source/Gui/TooglableButton.h b/Source/Gui/TooglableButton.h index 8305737..a68ad6d 100755 --- a/Source/Gui/TooglableButton.h +++ b/Source/Gui/TooglableButton.h @@ -45,20 +45,26 @@ public: public: class ToggleAttachment : public juce::AudioProcessorValueTreeState::ButtonAttachment { + RangedAudioParameter* parameter = nullptr; + TooglableButton* buttonToControl = nullptr; public: ToggleAttachment (juce::AudioProcessorValueTreeState& stateToControl, const juce::String& parameterID, - TooglableButton& buttonToControl) : AudioProcessorValueTreeState::ButtonAttachment (stateToControl, parameterID, buttonToControl) + TooglableButton& buttonToControl) : AudioProcessorValueTreeState::ButtonAttachment (stateToControl, parameterID, buttonToControl), buttonToControl(&buttonToControl) { - buttonToControl.setParameter (stateToControl.getParameter (parameterID)); + parameter = stateToControl.getParameter (parameterID); + buttonToControl.setParameter (parameter); } - + /* ToggleAttachment (juce::AudioProcessorValueTreeState& stateToControl, const juce::String& parameterID, Button& buttonToControl) : AudioProcessorValueTreeState::ButtonAttachment (stateToControl, parameterID, buttonToControl) { + }*/ + void updateToSlider(){ + float val = parameter->getValue(); + //buttonToControl->setValue(parameter->convertFrom0to1(val0to1), NotificationType::dontSendNotification); } - virtual ~ToggleAttachment() = default; }; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 473526e..f984b53 100755 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -442,6 +442,18 @@ void ObxdAudioProcessorEditor::rebuildComponents (ObxdAudioProcessor& ownerFilte //============================================================================== void ObxdAudioProcessorEditor::changeListenerCallback (ChangeBroadcaster* source) { + + for (int i = 0; i < knobAttachments.size(); i++){ + knobAttachments[i]->updateToSlider(); + } + + for (int i = 0; i < toggleAttachments.size(); i++){ + toggleAttachments[i]->updateToSlider(); + } + + for (int i = 0; i < buttonListAttachments.size(); i++){ + buttonListAttachments[i]->updateToSlider(); + } repaint(); } diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 0b15a79..539bb9a 100755 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -415,6 +415,7 @@ void ObxdAudioProcessor::setStateInformation(const void* data, int sizeInBytes) setCurrentProgram(xmlState->getIntAttribute(S("currentProgram"), 0)); + sendChangeMessage(); #if JUCE_VERSION <= JUCE_543 delete xmlState; #endif @@ -443,7 +444,8 @@ void ObxdAudioProcessor::setCurrentProgramStateInformation(const void* data, in programs.currentProgramPtr->name = e->getStringAttribute(S("programName"), S("Default")); setCurrentProgram(programs.currentProgram); - + + sendChangeMessage(); #if JUCE_VERSION <= JUCE_543 delete e; #endif @@ -740,6 +742,8 @@ void ObxdAudioProcessor::setEngineParameterValue (int index, float newValue) } programs.currentProgramPtr->values[index] = newValue; + apvtState.getParameter(getEngineParameterId(index))->setValue(newValue); + switch (index) {