diff --git a/Documents/discoDSP/OB-Xd/Skins/discoDSP Blue/main.png b/Documents/discoDSP/OB-Xd/Skins/discoDSP Blue/main.png index 1757375..09967df 100644 Binary files a/Documents/discoDSP/OB-Xd/Skins/discoDSP Blue/main.png and b/Documents/discoDSP/OB-Xd/Skins/discoDSP Blue/main.png differ diff --git a/Source/Gui/Knob.h b/Source/Gui/Knob.h index 916f232..a44c018 100755 --- a/Source/Gui/Knob.h +++ b/Source/Gui/Knob.h @@ -79,6 +79,7 @@ public: g.drawImage (kni, 0, 0, getWidth(), getHeight(), 0, h2 * ofs, w2, h2); } + ~Knob() override {}; private: Image kni; int fh, numFr; diff --git a/Source/Gui/TooglableButton.h b/Source/Gui/TooglableButton.h index fa572ac..8305737 100755 --- a/Source/Gui/TooglableButton.h +++ b/Source/Gui/TooglableButton.h @@ -38,7 +38,9 @@ public: h2 = height / 2; this->setClickingTogglesState (true); } - + ~TooglableButton() override{ + + }; // Source: https://git.iem.at/audioplugins/IEMPluginSuite/-/blob/master/resources/customComponents/ReverseSlider.h public: class ToggleAttachment : public juce::AudioProcessorValueTreeState::ButtonAttachment diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 319a9ca..3bdbcf1 100755 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -18,7 +18,17 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil { skinFolder = ownerFilter.getCurrentSkinFolder(); + loadSkin(processor); + //rebuildComponents (processor); + // + //clean(); + repaint(); +} + +void ObxdAudioProcessorEditor::loadSkin(ObxdAudioProcessor& ownerFilter){ + ownerFilter.removeChangeListener (this); //File coords("/Users/jimmy/Downloads/coords.xml"); + skinFolder = ownerFilter.getCurrentSkinFolder(); File coords = skinFolder.getChildFile ("coords.xml"); bool useClassicSkin = coords.existsAsFile(); if (!useClassicSkin) { @@ -29,8 +39,9 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil XmlDocument skin (coords); XmlElement* doc = skin.getDocumentElement(); if (doc) { + if (doc->getTagName() == "PROPERTIES"){ - + forEachXmlChildElementWithTagName(*doc, child, "VALUE"){ if (child->hasAttribute("NAME") && child->hasAttribute("x") && child->hasAttribute("y")) { String name = child->getStringAttribute("NAME"); @@ -39,6 +50,8 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil int d = child->getIntAttribute("d"); int w = child->getIntAttribute("w"); int h = child->getIntAttribute("h"); + + if (name == "guisize"){ setSize (x, y); } if (name == "resonanceKnob"){ resonanceKnob = addKnob (x, y, d, ownerFilter, RESONANCE, "Resonance", 0); } if (name == "cutoffKnob"){ cutoffKnob = addKnob (x, y, d, ownerFilter, CUTOFF, "Cutoff", 0.4); } @@ -130,11 +143,13 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil if (name == "filterDetuneKnob"){ filterDetuneKnob = addKnob (x, y, d, ownerFilter, FILTERDER, "Flt", 0.2); } if (name == "portamentoDetuneKnob"){ portamentoDetuneKnob = addKnob (x, y, d, ownerFilter, PORTADER, "Port", 0.2); } if (name == "envelopeDetuneKnob"){ envelopeDetuneKnob = addKnob (x, y, d, ownerFilter, ENVDER, "Env", 0.2); } - - if (name == "guisize"){ setSize (x, y); } - - if (name == "voiceSwitch"){ voiceSwitch = addList (x, y, w, h, ownerFilter, VOICE_COUNT, "VoiceCount", ImageCache::getFromFile(skinFolder.getChildFile("voices.png"))); } - if (name == "legatoSwitch"){ legatoSwitch = addList (x, y, w, h, ownerFilter, LEGATOMODE, "Legato", ImageCache::getFromFile(skinFolder.getChildFile("legato.png"))); } + + if (name == "voiceSwitch"){ + //if (voiceSwitch) voiceSwitch->setVisible(false); + voiceSwitch = addList (x, y, w, h, ownerFilter, VOICE_COUNT, "VoiceCount", ImageCache::getFromFile(skinFolder.getChildFile("voices.png"))); } + if (name == "legatoSwitch"){ + //if (legatoSwitch) legatoSwitch->setVisible(false); + legatoSwitch = addList (x, y, w, h, ownerFilter, LEGATOMODE, "Legato", ImageCache::getFromFile(skinFolder.getChildFile("legato.png"))); } //DBG(" Name: " << name << " X: " <addChoice (String (i)); + voiceSwitch ->setValue(ownerFilter.getParameter(VOICE_COUNT),dontSendNotification); } } if (legatoSwitch) { @@ -155,11 +171,12 @@ ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFil legatoSwitch->addChoice ("Keep Filter Envelope"); legatoSwitch->addChoice ("Keep Amplitude Envelope"); legatoSwitch->addChoice ("Retrig"); + legatoSwitch ->setValue(ownerFilter.getParameter(LEGATOMODE),dontSendNotification); } - //rebuildComponents (processor); + + ownerFilter.addChangeListener (this); repaint(); } - ObxdAudioProcessorEditor::~ObxdAudioProcessorEditor() { processor.removeChangeListener (this); @@ -197,7 +214,7 @@ Knob* ObxdAudioProcessorEditor::addKnob (int x, int y, int d, ObxdAudioProcessor knob->setRange (0, 1); addAndMakeVisible (knob); //addAndMakeVisible(knobl); - knob->setBounds (x, y, d, d); + knob->setBounds (x, y, d+(d/6), d+(d/6)); // knob->setValue (filter.getParameter (parameter), dontSendNotification); //knobl->setJustificationType(Justification::centred); //knobl->setInterceptsMouseClicks(false,true); @@ -214,6 +231,51 @@ Knob* ObxdAudioProcessorEditor::addKnob (int x, int y, int d, ObxdAudioProcessor return knob; } + +void ObxdAudioProcessorEditor::clean(){ + this->removeAllChildren(); + /* + //knobAttachments.clearQuick(true); + //toggleAttachments.clearQuick(true); + //buttonListAttachments.clearQuick(true); + + for (auto knob : {&cutoffKnob,&resonanceKnob,&osc1PitchKnob,&osc2PitchKnob,&osc2DetuneKnob,&volumeKnob, &portamentoKnob,&voiceDetuneKnob,&filterEnvelopeAmtKnob,&pulseWidthKnob,&xmodKnob,&multimodeKnob,&attackKnob,&decayKnob,&sustainKnob,&releaseKnob, + &fattackKnob,&fdecayKnob,&fsustainKnob,&freleaseKnob,&osc1MixKnob,&osc2MixKnob,&noiseMixKnob, + &filterDetuneKnob,&envelopeDetuneKnob,&portamentoDetuneKnob, + &tuneKnob, + &lfoFrequencyKnob,&lfoAmt1Knob,&lfoAmt2Knob, + &pan1Knob,&pan2Knob,&pan3Knob,&pan4Knob,&pan5Knob,&pan6Knob,&pan7Knob,&pan8Knob + }){ + if (*knob){ + (*knob)->deleteAllChildren(); + delete *knob; + *knob = nullptr; + } + } + + for (auto btn : {&osc1SawButton,&osc2SawButton,&osc1PulButton,&osc2PulButton,&filterKeyFollowButton,&unisonButton,&pitchQuantButton, + &filterHQButton,&filterBPBlendButton, + &lfoSinButton,&lfoSquareButton,&lfoSHButton,&lfoOsc1Button,&lfoOsc2Button,&lfoFilterButton, + &lfoPwm1Button,&lfoPwm2Button, + &bendRangeButton,&bendOsc2OnlyButton, + &fourPoleButton,&asPlayedAllocButton,&midiLearnButton,&midiUnlearnButton}){ + if (*btn){ + (*btn)->deleteAllChildren(); + delete *btn; + *btn = nullptr; + } + } + for (auto list :{ + &voiceSwitch,&legatoSwitch}){ + if (*list){ + (*list)->deleteAllChildren(); + delete *list; + *list = nullptr; + } + } + */ +} + TooglableButton* ObxdAudioProcessorEditor::addButton (int x, int y, ObxdAudioProcessor& filter, int parameter, String name) { TooglableButton* button = new TooglableButton (ImageCache::getFromFile(skinFolder.getChildFile("button.png"))); @@ -446,7 +508,9 @@ void ObxdAudioProcessorEditor::mouseUp(const MouseEvent& e) const File newSkinFolder = skins.getUnchecked(result); processor.setCurrentSkinFolder(newSkinFolder.getFileName()); - rebuildComponents (processor); + //rebuildComponents (processor); + clean(); + loadSkin(processor); } else if (result >= (bankStart + 1) && result <= (bankStart + banks.size())) { diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index c7d472c..fb79e8d 100755 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -32,7 +32,8 @@ class ObxdAudioProcessorEditor : public AudioProcessorEditor, public: ObxdAudioProcessorEditor(ObxdAudioProcessor& ownerFilter); ~ObxdAudioProcessorEditor(); - + + void mouseUp (const MouseEvent& e) override; void paint (Graphics& g) override; @@ -45,31 +46,32 @@ private: TooglableButton* addButton (int x, int y, ObxdAudioProcessor& filter, int parameter, String name); ButtonList* addList(int x, int y, int w, int h, ObxdAudioProcessor& filter, int parameter, String name, Image img); //Menu* addMenu (int x, int y); - + void clean(); + void rebuildComponents (ObxdAudioProcessor&); - + void loadSkin(ObxdAudioProcessor&); //============================================================================== ObxdAudioProcessor& processor; //============================================================================== - Knob* cutoffKnob,*resonanceKnob,*osc1PitchKnob,*osc2PitchKnob,*osc2DetuneKnob,*volumeKnob, - *portamentoKnob,*voiceDetuneKnob,*filterEnvelopeAmtKnob,*pulseWidthKnob,*xmodKnob,*multimodeKnob,*attackKnob,*decayKnob,*sustainKnob,*releaseKnob, - *fattackKnob,*fdecayKnob,*fsustainKnob,*freleaseKnob,*osc1MixKnob,*osc2MixKnob,*noiseMixKnob, - *filterDetuneKnob,*envelopeDetuneKnob,*portamentoDetuneKnob, - *tuneKnob, - *lfoFrequencyKnob,*lfoAmt1Knob,*lfoAmt2Knob, - *pan1Knob,*pan2Knob,*pan3Knob,*pan4Knob,*pan5Knob,*pan6Knob,*pan7Knob,*pan8Knob, - *brightnessKnob,*envPitchModKnob, - *bendLfoRateKnob,*veloAmpEnvKnob,*veloFltEnvKnob,*transposeKnob; + Knob* cutoffKnob=nullptr, *resonanceKnob=nullptr, *osc1PitchKnob=nullptr, *osc2PitchKnob=nullptr, *osc2DetuneKnob=nullptr, *volumeKnob, + *portamentoKnob=nullptr, *voiceDetuneKnob=nullptr, *filterEnvelopeAmtKnob=nullptr, *pulseWidthKnob=nullptr, *xmodKnob=nullptr, *multimodeKnob=nullptr, *attackKnob=nullptr, *decayKnob=nullptr, *sustainKnob=nullptr, *releaseKnob=nullptr, + *fattackKnob=nullptr, *fdecayKnob=nullptr, *fsustainKnob=nullptr, *freleaseKnob=nullptr, *osc1MixKnob=nullptr, *osc2MixKnob=nullptr, *noiseMixKnob=nullptr, + *filterDetuneKnob=nullptr, *envelopeDetuneKnob=nullptr, *portamentoDetuneKnob=nullptr, + *tuneKnob=nullptr, + *lfoFrequencyKnob=nullptr, *lfoAmt1Knob=nullptr, *lfoAmt2Knob=nullptr, + *pan1Knob=nullptr, *pan2Knob=nullptr, *pan3Knob=nullptr, *pan4Knob=nullptr, *pan5Knob=nullptr, *pan6Knob=nullptr, *pan7Knob=nullptr, *pan8Knob=nullptr, + *brightnessKnob=nullptr, *envPitchModKnob=nullptr, + *bendLfoRateKnob=nullptr, *veloAmpEnvKnob=nullptr, *veloFltEnvKnob=nullptr, *transposeKnob=nullptr; - TooglableButton* hardSyncButton,*osc1SawButton,*osc2SawButton,*osc1PulButton,*osc2PulButton,*filterKeyFollowButton,*unisonButton,*pitchQuantButton, - *filterHQButton,*filterBPBlendButton, - *lfoSinButton,*lfoSquareButton,*lfoSHButton,*lfoOsc1Button,*lfoOsc2Button,*lfoFilterButton, - *lfoPwm1Button,*lfoPwm2Button, - *bendRangeButton,*bendOsc2OnlyButton, - *fourPoleButton,*asPlayedAllocButton,*midiLearnButton,*midiUnlearnButton; + TooglableButton* hardSyncButton=nullptr, *osc1SawButton=nullptr, *osc2SawButton=nullptr, *osc1PulButton=nullptr, *osc2PulButton=nullptr, *filterKeyFollowButton=nullptr, *unisonButton=nullptr, *pitchQuantButton=nullptr, + *filterHQButton=nullptr, *filterBPBlendButton=nullptr, + *lfoSinButton=nullptr, *lfoSquareButton=nullptr, *lfoSHButton=nullptr, *lfoOsc1Button=nullptr, *lfoOsc2Button=nullptr, *lfoFilterButton, + *lfoPwm1Button=nullptr, *lfoPwm2Button=nullptr, + *bendRangeButton=nullptr, *bendOsc2OnlyButton=nullptr, + *fourPoleButton=nullptr, *asPlayedAllocButton=nullptr, *midiLearnButton=nullptr, *midiUnlearnButton=nullptr; - ButtonList *voiceSwitch,*legatoSwitch; + ButtonList *voiceSwitch = nullptr,*legatoSwitch = nullptr; File skinFolder;