diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1aa44cc3..97bd90ab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,10 +20,10 @@ Ownership --------- Since this project is under a dual license (free for non-commercial use, paid license for commercial use), -the sole ownership is with Foleys Finest Audio Ltd. By submitting your contributions you will not gain ownership +the sole ownership is with Foleys Finest Audio. By submitting your contributions you will not gain ownership over parts or the entirety of foleys_gui_magic. Any compensation is solely on the discretion of the owner. -Contributors declare, that they had ownership over the contributed code. Foleys Finest Audio Ltd. shall not be liable +Contributors declare, that they had ownership over the contributed code. Foleys Finest Audio shall not be liable for copyright or patent infringements through external contributors. If you have claims to any part inside the project, please get in touch and the code will be removed, if the claims are valid. diff --git a/Editor/foleys_GUITreeEditor.cpp b/Editor/foleys_GUITreeEditor.cpp index 0a1a62a0..e2d7a3d0 100644 --- a/Editor/foleys_GUITreeEditor.cpp +++ b/Editor/foleys_GUITreeEditor.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_GUITreeEditor.h b/Editor/foleys_GUITreeEditor.h index 1a0da034..bdec38ae 100644 --- a/Editor/foleys_GUITreeEditor.h +++ b/Editor/foleys_GUITreeEditor.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_MultiListPropertyComponent.cpp b/Editor/foleys_MultiListPropertyComponent.cpp index 8303c8c4..ff04733a 100644 --- a/Editor/foleys_MultiListPropertyComponent.cpp +++ b/Editor/foleys_MultiListPropertyComponent.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_MultiListPropertyComponent.h b/Editor/foleys_MultiListPropertyComponent.h index be2991cd..85d417c0 100644 --- a/Editor/foleys_MultiListPropertyComponent.h +++ b/Editor/foleys_MultiListPropertyComponent.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_Palette.cpp b/Editor/foleys_Palette.cpp index 40a4ca38..54a3d5a3 100644 --- a/Editor/foleys_Palette.cpp +++ b/Editor/foleys_Palette.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_Palette.h b/Editor/foleys_Palette.h index c7bd0d79..0ddf0070 100644 --- a/Editor/foleys_Palette.h +++ b/Editor/foleys_Palette.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_PropertiesEditor.cpp b/Editor/foleys_PropertiesEditor.cpp index b66405a4..77474d44 100644 --- a/Editor/foleys_PropertiesEditor.cpp +++ b/Editor/foleys_PropertiesEditor.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_PropertiesEditor.h b/Editor/foleys_PropertiesEditor.h index c32d97c1..bcb93709 100644 --- a/Editor/foleys_PropertiesEditor.h +++ b/Editor/foleys_PropertiesEditor.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StyleBoolPropertyComponent.cpp b/Editor/foleys_StyleBoolPropertyComponent.cpp index e62c2522..624432a6 100644 --- a/Editor/foleys_StyleBoolPropertyComponent.cpp +++ b/Editor/foleys_StyleBoolPropertyComponent.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StyleBoolPropertyComponent.h b/Editor/foleys_StyleBoolPropertyComponent.h index 76d2d046..8b910108 100644 --- a/Editor/foleys_StyleBoolPropertyComponent.h +++ b/Editor/foleys_StyleBoolPropertyComponent.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StyleChoicePropertyComponent.cpp b/Editor/foleys_StyleChoicePropertyComponent.cpp index d118c8d8..6785826b 100644 --- a/Editor/foleys_StyleChoicePropertyComponent.cpp +++ b/Editor/foleys_StyleChoicePropertyComponent.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StyleChoicePropertyComponent.h b/Editor/foleys_StyleChoicePropertyComponent.h index 8f08dc56..746c1f9b 100644 --- a/Editor/foleys_StyleChoicePropertyComponent.h +++ b/Editor/foleys_StyleChoicePropertyComponent.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StyleColourPropertyComponent.cpp b/Editor/foleys_StyleColourPropertyComponent.cpp index a8f4b10a..f32d769f 100644 --- a/Editor/foleys_StyleColourPropertyComponent.cpp +++ b/Editor/foleys_StyleColourPropertyComponent.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StyleColourPropertyComponent.h b/Editor/foleys_StyleColourPropertyComponent.h index 3b802481..98cdad9b 100644 --- a/Editor/foleys_StyleColourPropertyComponent.h +++ b/Editor/foleys_StyleColourPropertyComponent.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StyleGradientPropertyComponent.cpp b/Editor/foleys_StyleGradientPropertyComponent.cpp index 6c651370..93e860ba 100644 --- a/Editor/foleys_StyleGradientPropertyComponent.cpp +++ b/Editor/foleys_StyleGradientPropertyComponent.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StyleGradientPropertyComponent.h b/Editor/foleys_StyleGradientPropertyComponent.h index f34ff8bf..9098a4a0 100644 --- a/Editor/foleys_StyleGradientPropertyComponent.h +++ b/Editor/foleys_StyleGradientPropertyComponent.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StylePropertyComponent.cpp b/Editor/foleys_StylePropertyComponent.cpp index f5e3547e..ba34c384 100644 --- a/Editor/foleys_StylePropertyComponent.cpp +++ b/Editor/foleys_StylePropertyComponent.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StylePropertyComponent.h b/Editor/foleys_StylePropertyComponent.h index 8ad30ec1..9b55eb67 100644 --- a/Editor/foleys_StylePropertyComponent.h +++ b/Editor/foleys_StylePropertyComponent.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StyleTextPropertyComponent.cpp b/Editor/foleys_StyleTextPropertyComponent.cpp index 43d4155e..31a81628 100644 --- a/Editor/foleys_StyleTextPropertyComponent.cpp +++ b/Editor/foleys_StyleTextPropertyComponent.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_StyleTextPropertyComponent.h b/Editor/foleys_StyleTextPropertyComponent.h index c53f38e7..eac5493a 100644 --- a/Editor/foleys_StyleTextPropertyComponent.h +++ b/Editor/foleys_StyleTextPropertyComponent.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Editor/foleys_ToolBox.cpp b/Editor/foleys_ToolBox.cpp index 50aeef95..a3110c59 100644 --- a/Editor/foleys_ToolBox.cpp +++ b/Editor/foleys_ToolBox.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -193,7 +193,7 @@ void ToolBox::loadGUI (const juce::File& xmlFile) if (tree.isValid() && tree.getType() == IDs::magic) { - builder.setConfigTree (tree); + builder.getMagicState().setGuiValueTree (tree); stateWasReloaded(); } diff --git a/Editor/foleys_ToolBox.h b/Editor/foleys_ToolBox.h index 376f828b..606f2cd8 100644 --- a/Editor/foleys_ToolBox.h +++ b/Editor/foleys_ToolBox.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/General/foleys_ApplicationSettings.cpp b/General/foleys_ApplicationSettings.cpp index 18c044ed..9baa6598 100644 --- a/General/foleys_ApplicationSettings.cpp +++ b/General/foleys_ApplicationSettings.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2020 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -54,13 +54,17 @@ void ApplicationSettings::setFileName (juce::File file) return; settingsFile = file; - load(); + startTimerHz (1); } void ApplicationSettings::load() { juce::InterProcessLock lock (settingsFile.getFileName() + ".lock"); + auto newChecksum = juce::MD5 (settingsFile).toHexString(); + if (checksum == newChecksum) + return; + auto stream = settingsFile.createInputStream(); if (stream.get() == nullptr) return; @@ -70,6 +74,10 @@ void ApplicationSettings::load() return; settings.copyPropertiesAndChildrenFrom (tree, nullptr); + settings.addListener (this); + + checksum = newChecksum; + sendChangeMessage(); } void ApplicationSettings::save() @@ -86,6 +94,13 @@ void ApplicationSettings::save() stream->setPosition (0); stream->truncate(); stream->writeString (settings.toXmlString()); + + checksum = juce::MD5 (settingsFile).toHexString(); +} + +void ApplicationSettings::timerCallback() +{ + load(); } void ApplicationSettings::valueTreeChildAdded (juce::ValueTree&, juce::ValueTree&) diff --git a/General/foleys_ApplicationSettings.h b/General/foleys_ApplicationSettings.h index f65f9da8..28e57e40 100644 --- a/General/foleys_ApplicationSettings.h +++ b/General/foleys_ApplicationSettings.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2020 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -44,7 +44,9 @@ namespace foleys They are hierarchically ordered in a ValueTree and loaded via SharedResourcePointer, so they don't exist duplicated in one process. */ -class ApplicationSettings : private juce::ValueTree::Listener +class ApplicationSettings : public juce::ChangeBroadcaster, + private juce::Timer, + private juce::ValueTree::Listener { public: ApplicationSettings(); @@ -60,6 +62,7 @@ class ApplicationSettings : private juce::ValueTree::Listener void setFileName (juce::File file); private: + void timerCallback() override; void load(); void save(); @@ -70,6 +73,7 @@ class ApplicationSettings : private juce::ValueTree::Listener void valueTreePropertyChanged (juce::ValueTree&, const juce::Identifier&) override; juce::File settingsFile; + juce::String checksum; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ApplicationSettings) }; diff --git a/General/foleys_MagicGUIBuilder.cpp b/General/foleys_MagicGUIBuilder.cpp index 456ff0bd..18f7d131 100644 --- a/General/foleys_MagicGUIBuilder.cpp +++ b/General/foleys_MagicGUIBuilder.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -41,11 +41,13 @@ namespace foleys MagicGUIBuilder::MagicGUIBuilder (MagicGUIState& state) : magicState (state) { - config = juce::ValueTree (IDs::magic); - updateStylesheet(); } +MagicGUIBuilder::~MagicGUIBuilder() +{ +} + Stylesheet& MagicGUIBuilder::getStylesheet() { return stylesheet; @@ -53,12 +55,12 @@ Stylesheet& MagicGUIBuilder::getStylesheet() juce::ValueTree& MagicGUIBuilder::getConfigTree() { - return config; + return magicState.getGuiTree(); } juce::ValueTree MagicGUIBuilder::getGuiRootNode() { - return config.getChildWithName (IDs::view); + return getConfigTree().getOrCreateChildWithName (IDs::view, &undo); } std::unique_ptr MagicGUIBuilder::createGuiItem (const juce::ValueTree& node) @@ -85,7 +87,7 @@ std::unique_ptr MagicGUIBuilder::createGuiItem (const juce::ValueTree& void MagicGUIBuilder::updateStylesheet() { - auto stylesNode = config.getOrCreateChildWithName (IDs::styles, &undo); + auto stylesNode = getConfigTree().getOrCreateChildWithName (IDs::styles, &undo); if (stylesNode.getNumChildren() == 0) stylesNode.appendChild (magicState.createDefaultStylesheet(), &undo); @@ -106,7 +108,7 @@ void MagicGUIBuilder::updateStylesheet() void MagicGUIBuilder::clearGUI() { - auto guiNode = config.getOrCreateChildWithName (IDs::view, &undo); + auto guiNode = getConfigTree().getOrCreateChildWithName (IDs::view, &undo); guiNode.removeAllChildren (&undo); guiNode.removeAllProperties (&undo); @@ -115,7 +117,7 @@ void MagicGUIBuilder::clearGUI() void MagicGUIBuilder::resetToDefaultGUI() { - auto guiNode = config.getOrCreateChildWithName (IDs::view, &undo); + auto guiNode = getConfigTree().getOrCreateChildWithName (IDs::view, &undo); guiNode.removeAllChildren (&undo); guiNode.removeAllProperties (&undo); guiNode.copyPropertiesAndChildrenFrom (magicState.createDefaultGUITree(), &undo); @@ -139,35 +141,6 @@ void MagicGUIBuilder::closeOverlayDialog() overlayDialog.reset(); } -void MagicGUIBuilder::setConfigTree (const juce::ValueTree& gui) -{ - if (gui.isValid() == false) - return; - - if (config.isValid()) - { - auto parentNode = config.getParent(); - parentNode.removeChild (config, nullptr); - config = gui; - if (parentNode.isValid()) - parentNode.appendChild (config, nullptr); - } - else - { - config = gui; - } - - undo.clearUndoHistory(); - updateComponents(); -} - -void MagicGUIBuilder::setConfigTree (const char* data, int dataSize) -{ - juce::String text (data, size_t (dataSize)); - auto gui = juce::ValueTree::fromXml (text); - setConfigTree (gui); -} - void MagicGUIBuilder::createGUI (juce::Component& parentToUse) { parent = &parentToUse; @@ -187,12 +160,10 @@ void MagicGUIBuilder::updateComponents() updateStylesheet(); - if (config.getChildWithName (IDs::view).isValid() == false) - config.appendChild (magicState.createDefaultGUITree(), &undo); - - auto rootNode = config.getOrCreateChildWithName (IDs::view, &undo); +// if (config.getChildWithName (IDs::view).isValid() == false) +// config.appendChild (magicState.createDefaultGUITree(), &undo); - root = createGuiItem (rootNode); + root = createGuiItem (getGuiRootNode()); parent->addAndMakeVisible (root.get()); root->setBounds (parent->getLocalBounds()); diff --git a/General/foleys_MagicGUIBuilder.h b/General/foleys_MagicGUIBuilder.h index 8046df2f..6d1ce723 100644 --- a/General/foleys_MagicGUIBuilder.h +++ b/General/foleys_MagicGUIBuilder.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -48,16 +48,7 @@ class MagicGUIBuilder : public juce::ChangeListener { public: MagicGUIBuilder (MagicGUIState& magicStateToUse); - - /** - Allows to set the GUI definition when reloading - */ - void setConfigTree (const juce::ValueTree& config); - - /** - Convenience method to call setConfigTree directly from BinaryData - */ - void setConfigTree (const char* data, int dataSize); + ~MagicGUIBuilder() override; /** Create a node from the description @@ -226,7 +217,6 @@ class MagicGUIBuilder : public juce::ChangeListener private: juce::UndoManager undo; - juce::ValueTree config; Stylesheet stylesheet { *this }; //============================================================================== diff --git a/General/foleys_MagicJUCEFactories.cpp b/General/foleys_MagicJUCEFactories.cpp index 122c5273..bf37c1ee 100644 --- a/General/foleys_MagicJUCEFactories.cpp +++ b/General/foleys_MagicJUCEFactories.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -144,7 +144,7 @@ class SliderItem : public GuiItem private: AutoOrientationSlider slider; - std::unique_ptr attachment; + std::unique_ptr attachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SliderItem) }; @@ -213,7 +213,7 @@ class ComboBoxItem : public GuiItem private: juce::ComboBox comboBox; - std::unique_ptr attachment; + std::unique_ptr attachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBoxItem) }; @@ -249,6 +249,7 @@ class TextButtonItem : public GuiItem if (parameter.isNotEmpty()) attachment = getMagicState().createAttachment (parameter, button); + button.setClickingTogglesState (parameter.isNotEmpty()); button.setButtonText (magicBuilder.getStyleProperty (pText, configNode)); auto triggerID = getProperty (pOnClick).toString(); @@ -274,7 +275,7 @@ class TextButtonItem : public GuiItem private: juce::TextButton button; - std::unique_ptr attachment; + std::unique_ptr attachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButtonItem) }; @@ -334,7 +335,7 @@ class ToggleButtonItem : public GuiItem private: juce::ToggleButton button; - std::unique_ptr attachment; + std::unique_ptr attachment; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleButtonItem) }; @@ -699,6 +700,12 @@ class ListBoxItem : public GuiItem, addAndMakeVisible (listBox); } + ~ListBoxItem() override + { + if (auto* m = dynamic_cast(listBox.getModel())) + m->removeChangeListener (this); + } + void update() override { if (auto* m = dynamic_cast(listBox.getModel())) diff --git a/General/foleys_MagicPluginEditor.cpp b/General/foleys_MagicPluginEditor.cpp index 98607cd9..a743cf81 100644 --- a/General/foleys_MagicPluginEditor.cpp +++ b/General/foleys_MagicPluginEditor.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -71,7 +71,7 @@ void MagicPluginEditor::initialise (const char* data, int dataSize) if (builder.get() == nullptr) builder = createBuilderInstance(); - auto guiTree = processorState.getValueTreeState().state.getChildWithName ("magic"); + auto guiTree = processorState.getValueTree().getChildWithName ("magic"); if (guiTree.isValid()) setConfigTree (guiTree); else if (data != nullptr) @@ -82,8 +82,8 @@ void MagicPluginEditor::initialise (const char* data, int dataSize) updateSize(); #if FOLEYS_SHOW_GUI_EDITOR_PALLETTE - if (!guiTree.isValid() && processorState.getValueTreeState().state.isValid()) - processorState.getValueTreeState().state.addChild (builder->getConfigTree(), -1, nullptr); + if (!guiTree.isValid() && processorState.getValueTree().isValid()) + processorState.getValueTree().addChild (builder->getConfigTree(), -1, nullptr); builder->attachToolboxToWindow (*this); #endif @@ -136,7 +136,7 @@ void MagicPluginEditor::setConfigTree (const juce::ValueTree& gui) if (! rootNode.hasProperty (IDs::resizable)) rootNode.setProperty (IDs::resizable, true, &undo); if (! rootNode.hasProperty (IDs::resizeCorner)) rootNode.setProperty (IDs::resizeCorner, true, &undo); - builder->setConfigTree (gui); + processorState.setGuiValueTree (gui); builder->createGUI (*this); updateSize(); diff --git a/General/foleys_MagicPluginEditor.h b/General/foleys_MagicPluginEditor.h index 502b6eae..8ec8699d 100644 --- a/General/foleys_MagicPluginEditor.h +++ b/General/foleys_MagicPluginEditor.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/General/foleys_MagicProcessor.cpp b/General/foleys_MagicProcessor.cpp new file mode 100644 index 00000000..24123a9c --- /dev/null +++ b/General/foleys_MagicProcessor.cpp @@ -0,0 +1,92 @@ +/* + ============================================================================== + Copyright (c) 2021 Foleys Finest Audio - Daniel Walz + All rights reserved. + + License for non-commercial projects: + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + + License for commercial products: + + To sell commercial products containing this module, you are required to buy a + License from https://foleysfinest.com/developer/pluginguimagic/ + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + ============================================================================== + */ + +#pragma once + +namespace foleys +{ + + +MagicProcessor::MagicProcessor() +#ifndef JucePlugin_PreferredChannelConfigurations + : juce::AudioProcessor (juce::AudioProcessor::BusesProperties() + #if ! JucePlugin_IsMidiEffect + #if ! JucePlugin_IsSynth + .withInput ("Input", juce::AudioChannelSet::stereo(), true) + #endif + .withOutput ("Output", juce::AudioChannelSet::stereo(), true) + #endif + ) +#endif +{} + +MagicProcessor::MagicProcessor (const BusesProperties& ioLayouts) : juce::AudioProcessor (ioLayouts) +{} + +MagicProcessor::MagicProcessor (const std::initializer_list& channelLayoutList) : juce::AudioProcessor (channelLayoutList) +{} + +//============================================================================== +void MagicProcessor::initialiseBuilder (MagicGUIBuilder& builder) +{ + builder.registerJUCEFactories(); + builder.registerJUCELookAndFeels(); +} + +juce::AudioProcessorEditor* MagicProcessor::createEditor() +{ + magicState.updateParameterMap(); + + auto builder = std::make_unique(magicState); + initialiseBuilder (*builder); + + return new MagicPluginEditor (magicState, std::move (builder)); +} + +//============================================================================== +void MagicProcessor::getStateInformation (juce::MemoryBlock& destData) +{ + magicState.getStateInformation (destData); +} + +void MagicProcessor::setStateInformation (const void* data, int sizeInBytes) +{ + magicState.setStateInformation (data, sizeInBytes, getActiveEditor()); + + postSetStateInformation(); +} + +} // namespace foleys diff --git a/General/foleys_MagicProcessor.h b/General/foleys_MagicProcessor.h new file mode 100644 index 00000000..2042ea17 --- /dev/null +++ b/General/foleys_MagicProcessor.h @@ -0,0 +1,124 @@ +/* + ============================================================================== + Copyright (c) 2021 Foleys Finest Audio - Daniel Walz + All rights reserved. + + License for non-commercial projects: + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + + License for commercial products: + + To sell commercial products containing this module, you are required to buy a + License from https://foleysfinest.com/developer/pluginguimagic/ + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + ============================================================================== + */ + +#pragma once + +namespace foleys +{ + +/** + This is a convenience class to create a plugin using PluginGuiMagic. It has all wired up for you, + The MagicPluginEditor for you to design or use the generic default, the loading and saving of the state + and many more. + */ +class MagicProcessor : public juce::AudioProcessor +{ +public: + MagicProcessor(); + MagicProcessor (const BusesProperties& ioLayouts); + MagicProcessor (const std::initializer_list& channelLayoutList); + + /** + Override that method to initialise the builder, register your own bespoke components or LookAndFeel classes + */ + virtual void initialiseBuilder (MagicGUIBuilder& builder); + + /** + If there is anything you need to do after a new state was loaded you can override this method + */ + virtual void postSetStateInformation() {} + + //============================================================================== + juce::AudioProcessorEditor* createEditor() override; + bool hasEditor() const override { return true; } + + //============================================================================== + void getStateInformation (juce::MemoryBlock& destData) override; + void setStateInformation (const void* data, int sizeInBytes) override; + + //============================================================================== + int getNumPrograms() override { return 1; } + int getCurrentProgram() override { return 0; } + void setCurrentProgram (int index) override { juce::ignoreUnused (index); } + const juce::String getProgramName (int index) override { juce::ignoreUnused (index); return "default"; } + void changeProgramName (int index, const juce::String& newName) override { juce::ignoreUnused (index, newName); } + + //============================================================================== +#ifdef JucePlugin_Name + const juce::String getName() const override { return JucePlugin_Name; } +#endif + +#ifdef JucePlugin_WantsMidiInput + bool acceptsMidi() const override + { + #if JucePlugin_WantsMidiInput + return true; + #else + return false; + #endif + } +#endif + +#ifdef JucePlugin_ProducesMidiOutput + bool producesMidi() const override + { + #if JucePlugin_ProducesMidiOutput + return true; + #else + return false; + #endif + } +#endif + +#ifdef JucePlugin_IsMidiEffect + bool isMidiEffect() const override + { + #if JucePlugin_IsMidiEffect + return true; + #else + return false; + #endif + } +#endif + +protected: + MagicProcessorState magicState { *this }; + +private: + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MagicProcessor) +}; + +} // namespace foleys diff --git a/General/foleys_Resources.cpp b/General/foleys_Resources.cpp index 09dcaf68..60a85229 100644 --- a/General/foleys_Resources.cpp +++ b/General/foleys_Resources.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/General/foleys_Resources.h b/General/foleys_Resources.h index d235f6b2..5de1cd56 100644 --- a/General/foleys_Resources.h +++ b/General/foleys_Resources.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/General/foleys_SettableProperties.h b/General/foleys_SettableProperties.h index e0992aa8..f49bd0d0 100644 --- a/General/foleys_SettableProperties.h +++ b/General/foleys_SettableProperties.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/General/foleys_StringDefinitions.h b/General/foleys_StringDefinitions.h index f9fab8ef..a410ba03 100644 --- a/General/foleys_StringDefinitions.h +++ b/General/foleys_StringDefinitions.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -158,6 +158,7 @@ namespace IDs static juce::Identifier width { "width" }; static juce::Identifier height { "height" }; + static juce::Identifier properties { "Properties" }; static juce::Identifier lastSize { "last-size" }; } diff --git a/Helpers/foleys_AtomicValueAttachment.h b/Helpers/foleys_AtomicValueAttachment.h index f8b3825a..0a7e6ef1 100644 --- a/Helpers/foleys_AtomicValueAttachment.h +++ b/Helpers/foleys_AtomicValueAttachment.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Helpers/foleys_Conversions.h b/Helpers/foleys_Conversions.h index 335ccb41..04683457 100644 --- a/Helpers/foleys_Conversions.h +++ b/Helpers/foleys_Conversions.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Helpers/foleys_MouseLambdas.h b/Helpers/foleys_MouseLambdas.h index 55dff648..a999fc1c 100644 --- a/Helpers/foleys_MouseLambdas.h +++ b/Helpers/foleys_MouseLambdas.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Helpers/foleys_ParameterAttachment.h b/Helpers/foleys_ParameterAttachment.h index db29d5e5..52c16cde 100644 --- a/Helpers/foleys_ParameterAttachment.h +++ b/Helpers/foleys_ParameterAttachment.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Helpers/foleys_PopupMenuHelper.h b/Helpers/foleys_PopupMenuHelper.h index cc252f97..9de60dda 100644 --- a/Helpers/foleys_PopupMenuHelper.h +++ b/Helpers/foleys_PopupMenuHelper.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/LICENSE.md b/LICENSE.md index 1e36ea50..3af168ed 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -21,7 +21,7 @@ under the terms of the BSD 3-Clause License: **BSD 3-Clause License** -Copyright (c) 2019, Foleys Finest Audio Ltd. - Daniel Walz +Copyright (c) 2019, Foleys Finest Audio - Daniel Walz All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Layout/foleys_BoxModel.h b/Layout/foleys_BoxModel.h index 13e84fc2..33eeaf83 100644 --- a/Layout/foleys_BoxModel.h +++ b/Layout/foleys_BoxModel.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Layout/foleys_Container.cpp b/Layout/foleys_Container.cpp index 66e6ce6a..1f8d5647 100644 --- a/Layout/foleys_Container.cpp +++ b/Layout/foleys_Container.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Layout/foleys_Container.h b/Layout/foleys_Container.h index 0b85d68d..7549207f 100644 --- a/Layout/foleys_Container.h +++ b/Layout/foleys_Container.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Layout/foleys_Decorator.cpp b/Layout/foleys_Decorator.cpp index 1bd1125f..ab9ab52b 100644 --- a/Layout/foleys_Decorator.cpp +++ b/Layout/foleys_Decorator.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Layout/foleys_Decorator.h b/Layout/foleys_Decorator.h index 40c884ef..48edb5a6 100644 --- a/Layout/foleys_Decorator.h +++ b/Layout/foleys_Decorator.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Layout/foleys_GradientBackground.cpp b/Layout/foleys_GradientBackground.cpp index 646230d2..6c701568 100644 --- a/Layout/foleys_GradientBackground.cpp +++ b/Layout/foleys_GradientBackground.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Layout/foleys_GradientBackground.h b/Layout/foleys_GradientBackground.h index 816a8aaa..aa5a7682 100644 --- a/Layout/foleys_GradientBackground.h +++ b/Layout/foleys_GradientBackground.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Layout/foleys_GuiItem.cpp b/Layout/foleys_GuiItem.cpp index f2a94490..c2f1824c 100644 --- a/Layout/foleys_GuiItem.cpp +++ b/Layout/foleys_GuiItem.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Layout/foleys_GuiItem.h b/Layout/foleys_GuiItem.h index 68b3240c..71a55056 100644 --- a/Layout/foleys_GuiItem.h +++ b/Layout/foleys_GuiItem.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Layout/foleys_Stylesheet.cpp b/Layout/foleys_Stylesheet.cpp index 9e28d13b..fdf08386 100644 --- a/Layout/foleys_Stylesheet.cpp +++ b/Layout/foleys_Stylesheet.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Layout/foleys_Stylesheet.h b/Layout/foleys_Stylesheet.h index 25b665f4..6f3a00c3 100644 --- a/Layout/foleys_Stylesheet.h +++ b/Layout/foleys_Stylesheet.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/LookAndFeels/foleys_LookAndFeel.cpp b/LookAndFeels/foleys_LookAndFeel.cpp index 1371883c..ad38d0c3 100644 --- a/LookAndFeels/foleys_LookAndFeel.cpp +++ b/LookAndFeels/foleys_LookAndFeel.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/LookAndFeels/foleys_LookAndFeel.h b/LookAndFeels/foleys_LookAndFeel.h index 0b1796d8..f4bc15cd 100644 --- a/LookAndFeels/foleys_LookAndFeel.h +++ b/LookAndFeels/foleys_LookAndFeel.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/LookAndFeels/foleys_Skeuomorphic.cpp b/LookAndFeels/foleys_Skeuomorphic.cpp index 5ca5058a..7400ba58 100644 --- a/LookAndFeels/foleys_Skeuomorphic.cpp +++ b/LookAndFeels/foleys_Skeuomorphic.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/LookAndFeels/foleys_Skeuomorphic.h b/LookAndFeels/foleys_Skeuomorphic.h index 636c4b73..c0db4626 100644 --- a/LookAndFeels/foleys_Skeuomorphic.h +++ b/LookAndFeels/foleys_Skeuomorphic.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/README.md b/README.md index 7109422b..4094cd8d 100644 --- a/README.md +++ b/README.md @@ -21,29 +21,24 @@ Setup ----- To use the WYSWYG plugin editor, add this module via Projucer to your JUCE project. -Remove the PluginEditor, that was automatically created by Projucer. Instead add a member -called `foleys::MagicProcessorState` to your processor and create a `foleys::MagicPluginEditor` -in the `createEditor()` method of your processor: -``` -// assumes an AudioProcessorValueTreeState named treeState -foleys::MagicProcessorState magicState { *this, treeState }; - -// return a new editor: -AudioProcessorEditor* EqualizerExampleAudioProcessor::createEditor() -{ - // MAGIC GUI: create the generated editor, load your GUI from magic.xml in the binary resources - // if you haven't created one yet, just give it a magicState and remove the last two arguments - return new foleys::MagicPluginEditor (magicState, BinaryData::magic_xml, BinaryData::magic_xmlSize); -} -``` +Instead of inheriting from juce::AudioProcessor inherit foleys::MagicProcessor. +Get rid of those methods: +- bool hasEditor() +- juce::PluginEditor* createEditor() +- void setStateInformation() and void getStateInformation() (optional, a default saving and loading method is provided) + +The foleys::MagicProcessor will provide a `foleys::MagicProcessorState magicState` (protected visibility) +to add visualisations or other objects to expose to the GUI. + +It is also possible to use the module in an Application. In that case you add a `MagicGuiState` and a `MagicGUIBuilder` yourself. +There is an example available in the examples repository called PlayerExample. Add Visualisations ------------------ -To add visualisations like an Analyser or Oscilloscope to your plugin, add them in the constructor -to the `foleys::MagicPluginState`: +To add visualisations like an Analyser or Oscilloscope to your plugin, add them in the constructor: ``` // Member: @@ -51,7 +46,6 @@ foleys::MagicPlotSource* analyser = nullptr; // Constructor analyser = magicState.createAndAddObject("input"); -magicState.addBackgroundProcessing (analyser); // prepareToPlay analyser->prepareToPlay (sampleRate, samplesPerBlockExpected); @@ -67,24 +61,18 @@ case "input". Saving and restoring the plugin ------------------------------- -You can save and restore your plugin state, just as you have been used to. But you can also delegate -this to the `foleys::MagicPluginState`, which will additionally save and restore your PluginEditor's -last size: +The `foleys::MagicProcessor` takes care of saving and restoring the parameters and properties. +You can add your own values to the ValueTree in the `magicState`. +There is a callback after restoring that you can override, in case you need to do some additional action. + + +Bake in the xml +--------------- +To bake in the GUI save the XML from the PGM panel and add it to the BinaryResources via Projucer. +In the constructor you set the XML file: ``` -void getStateInformation (MemoryBlock& destData) override -{ - // MAGIC GUI: let the magicState conveniently handle save and restore the state. - // You don't need to use that, but it also takes care of restoring the last editor size - magicState.getStateInformation (destData); -} - -void setStateInformation (const void* data, int sizeInBytes) override -{ - // MAGIC GUI: let the magicState conveniently handle save and restore the state. - // You don't need to use that, but it also takes care of restoring the last editor size - magicState.setStateInformation (data, sizeInBytes, getActiveEditor()); -} +magicState.setGuiValueTree (BinaryData::magic_xml, BinaryData::magic_xmlSize); ``` diff --git a/General/foleys_MagicGUIState.cpp b/State/foleys_MagicGUIState.cpp similarity index 88% rename from General/foleys_MagicGUIState.cpp rename to State/foleys_MagicGUIState.cpp index b6f7c189..2db384a6 100644 --- a/General/foleys_MagicGUIState.cpp +++ b/State/foleys_MagicGUIState.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -38,6 +38,9 @@ namespace foleys { +MagicGUIState::MagicGUIState() +{ +} MagicGUIState::~MagicGUIState() { @@ -67,9 +70,37 @@ std::function MagicGUIState::getTrigger (const juce::Identifier& trigger return it->second; } +juce::ValueTree MagicGUIState::getPropertyRoot() +{ + return state.getOrCreateChildWithName (IDs::properties, nullptr); +} + juce::ValueTree MagicGUIState::getPropertyRoot() const { - return propertyRoot; + return state.getChildWithName (IDs::properties); +} + +void MagicGUIState::setGuiValueTree (const juce::ValueTree& dom) +{ + guiValueTree = dom; +} + +void MagicGUIState::setGuiValueTree (const char* data, int dataSize) +{ + juce::String text (data, size_t (dataSize)); + auto dom = juce::ValueTree::fromXml (text); + if (dom.isValid()) + setGuiValueTree (dom); +} + +juce::ValueTree& MagicGUIState::getGuiTree() +{ + return guiValueTree; +} + +juce::ValueTree& MagicGUIState::getValueTree() +{ + return state; } void MagicGUIState::setApplicationSettingsFile (juce::File file) @@ -77,6 +108,11 @@ void MagicGUIState::setApplicationSettingsFile (juce::File file) settings->setFileName (file); } +juce::ValueTree& MagicGUIState::getSettings() +{ + return settings->settings; +} + juce::ValueTree MagicGUIState::createDefaultStylesheet() const { return Stylesheet::createDefaultStyle(); diff --git a/General/foleys_MagicGUIState.h b/State/foleys_MagicGUIState.h similarity index 85% rename from General/foleys_MagicGUIState.h rename to State/foleys_MagicGUIState.h index 9c6ec6b6..7be5f9df 100644 --- a/General/foleys_MagicGUIState.h +++ b/State/foleys_MagicGUIState.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -63,32 +63,51 @@ class MagicGUIState } public: - MagicGUIState() = default; + MagicGUIState(); virtual ~MagicGUIState(); /** Returns the root node for exposed properties for the GUI */ - virtual juce::ValueTree getPropertyRoot() const; + juce::ValueTree getPropertyRoot(); + juce::ValueTree getPropertyRoot() const; + + /** + Set the GUI DOM to create the GUI components from + */ + void setGuiValueTree (const juce::ValueTree& dom); + void setGuiValueTree (const char* data, int dataSize); + + /** + Grants access to the gui tree. This is returned as reference so you are able to connect listeners to it. + */ + juce::ValueTree& getGuiTree(); + + juce::ValueTree& getValueTree(); /** Set a file to save common settings for all instances */ void setApplicationSettingsFile (juce::File file); + /** + This is a settings ValueTree that is stored globally for all plugin instances + */ + juce::ValueTree& getSettings(); + /** Returns the IDs of AudioProcessorParameters for selection */ virtual juce::StringArray getParameterNames() const; - virtual juce::RangedAudioParameter* getParameter ([[maybe_unused]]const juce::String& paramID) + virtual juce::RangedAudioParameter* getParameter (const juce::String& paramID) { juce::ignoreUnused(paramID); return nullptr; } - virtual std::unique_ptr createAttachment (const juce::String& paramID, juce::Slider&) + virtual std::unique_ptr createAttachment (const juce::String& paramID, juce::Slider&) { juce::ignoreUnused(paramID); return nullptr; } - virtual std::unique_ptr createAttachment (const juce::String& paramID, juce::ComboBox&) + virtual std::unique_ptr createAttachment (const juce::String& paramID, juce::ComboBox&) { juce::ignoreUnused(paramID); return nullptr; } - virtual std::unique_ptr createAttachment (const juce::String& paramID, juce::Button&) + virtual std::unique_ptr createAttachment (const juce::String& paramID, juce::Button&) { juce::ignoreUnused(paramID); return nullptr; } /** @@ -152,6 +171,9 @@ class MagicGUIState auto* pointerToReturn = o.get(); advertisedObjects [objectID] = std::move (o); + if (auto* plot = dynamic_cast(pointerToReturn)) + addBackgroundProcessing (plot); + return pointerToReturn; } @@ -213,7 +235,8 @@ class MagicGUIState */ SharedApplicationSettings settings; - juce::ValueTree propertyRoot { "Properties" }; + juce::ValueTree guiValueTree { "magic" }; + juce::ValueTree state { "state" }; juce::MidiKeyboardState keyboardState; diff --git a/General/foleys_MagicProcessorState.cpp b/State/foleys_MagicProcessorState.cpp similarity index 78% rename from General/foleys_MagicProcessorState.cpp rename to State/foleys_MagicProcessorState.cpp index 112bb0fd..e4ac4de3 100644 --- a/General/foleys_MagicProcessorState.cpp +++ b/State/foleys_MagicProcessorState.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -38,28 +38,14 @@ namespace foleys { -MagicProcessorState::MagicProcessorState (juce::AudioProcessor& processorToUse, - juce::AudioProcessorValueTreeState& stateToUse) - : MagicGUIState(), - processor (processorToUse), - state (stateToUse) +MagicProcessorState::MagicProcessorState (juce::AudioProcessor& processorToUse) + : processor (processorToUse) { - midiMapper.setAudioProcessorValueTreeState (&state); -} - -juce::ValueTree MagicProcessorState::getPropertyRoot() const -{ - return state.state.getOrCreateChildWithName ("properties", nullptr); } juce::StringArray MagicProcessorState::getParameterNames() const { - juce::StringArray names; - for (const auto* p : processor.getParameters()) - if (const auto* withID = dynamic_cast(p)) - names.add (withID->paramID); - - return names; + return parameters.getParameterNames(); } juce::PopupMenu MagicProcessorState::createParameterMenu() const @@ -90,22 +76,45 @@ void MagicProcessorState::addParametersToMenu (const juce::AudioProcessorParamet juce::RangedAudioParameter* MagicProcessorState::getParameter (const juce::String& paramID) { - return state.getParameter (paramID); + return parameters.getParameter (paramID); } -std::unique_ptr MagicProcessorState::createAttachment (const juce::String& paramID, juce::Slider& slider) +void MagicProcessorState::updateParameterMap() { - return std::make_unique(state, paramID, slider); + parameters.updateParameterMap(); } -std::unique_ptr MagicProcessorState::createAttachment (const juce::String& paramID, juce::ComboBox& combobox) +std::unique_ptr MagicProcessorState::createAttachment (const juce::String& paramID, juce::Slider& slider) { - return std::make_unique(state, paramID, combobox); + if (auto* parameter = getParameter (paramID)) + return std::make_unique(*parameter, slider); + + // You have connected a control to a parameter that doesn't exist. Please fix your GUI. + // You may safely click continue in your debugger + jassertfalse; + return {}; } -std::unique_ptr MagicProcessorState::createAttachment (const juce::String& paramID, juce::Button& button) +std::unique_ptr MagicProcessorState::createAttachment (const juce::String& paramID, juce::ComboBox& combobox) { - return std::make_unique(state, paramID, button); + if (auto* parameter = getParameter (paramID)) + return std::make_unique(*parameter, combobox); + + // You have connected a control to a parameter that doesn't exist. Please fix your GUI. + // You may safely click continue in your debugger + jassertfalse; + return {}; +} + +std::unique_ptr MagicProcessorState::createAttachment (const juce::String& paramID, juce::Button& button) +{ + if (auto* parameter = getParameter (paramID)) + return std::make_unique(*parameter, button); + + // You have connected a control to a parameter that doesn't exist. Please fix your GUI. + // You may safely click continue in your debugger + jassertfalse; + return {}; } juce::AudioProcessor* MagicProcessorState::getProcessor() @@ -115,20 +124,14 @@ juce::AudioProcessor* MagicProcessorState::getProcessor() void MagicProcessorState::setLastEditorSize (int width, int height) { - if (state.state.isValid() == false) - return; - - auto sizeNode = state.state.getOrCreateChildWithName (IDs::lastSize, nullptr); + auto sizeNode = getValueTree().getOrCreateChildWithName (IDs::lastSize, nullptr); sizeNode.setProperty (IDs::width, width, nullptr); sizeNode.setProperty (IDs::height, height, nullptr); } bool MagicProcessorState::getLastEditorSize (int& width, int& height) { - if (state.state.isValid() == false) - return false; - - auto sizeNode = state.state.getOrCreateChildWithName (IDs::lastSize, nullptr); + auto sizeNode = getValueTree().getOrCreateChildWithName (IDs::lastSize, nullptr); if (sizeNode.hasProperty (IDs::width) == false || sizeNode.hasProperty (IDs::height) == false) return false; @@ -139,8 +142,11 @@ bool MagicProcessorState::getLastEditorSize (int& width, int& height) void MagicProcessorState::getStateInformation (juce::MemoryBlock& destData) { + auto state = getValueTree(); + parameters.saveParameterValues (state); + juce::MemoryOutputStream stream (destData, false); - state.state.writeToStream (stream); + state.writeToStream (stream); } void MagicProcessorState::setStateInformation (const void* data, int sizeInBytes, juce::AudioProcessorEditor* editor) @@ -149,7 +155,13 @@ void MagicProcessorState::setStateInformation (const void* data, int sizeInBytes if (tree.isValid() == false) return; - state.replaceState (tree); + auto state = getValueTree(); + if (state.getType() != tree.getType()) + return; + + state.copyPropertiesAndChildrenFrom (tree, nullptr); + + parameters.loadParameterValues (state); if (editor) { @@ -229,11 +241,11 @@ juce::ValueTree MagicProcessorState::createDefaultGUITree() const current.appendChild (child, nullptr); - juce::ValueTree parameters { IDs::view, { + juce::ValueTree params { IDs::view, { { IDs::styleClass, "parameters nomargin" }}}; - current.appendChild (parameters, nullptr); - current = parameters; + current.appendChild (params, nullptr); + current = params; } createDefaultFromParameters (current, processor.getParameterTree()); @@ -280,9 +292,4 @@ void MagicProcessorState::timerCallback() getPropertyAsValue ("playhead:isRecording").setValue (isRecording.load()); } -juce::AudioProcessorValueTreeState& MagicProcessorState::getValueTreeState() -{ - return state; -} - } // namespace foleys diff --git a/General/foleys_MagicProcessorState.h b/State/foleys_MagicProcessorState.h similarity index 86% rename from General/foleys_MagicProcessorState.h rename to State/foleys_MagicProcessorState.h index ff96cb5a..91cdf23b 100644 --- a/General/foleys_MagicProcessorState.h +++ b/State/foleys_MagicProcessorState.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -52,13 +52,7 @@ class MagicProcessorState : public MagicGUIState, Create a MagicProcessorState to let the generated GUI communicate with the processor and it's internals. */ - MagicProcessorState (juce::AudioProcessor& processorToUse, - juce::AudioProcessorValueTreeState& stateToUse); - - /** - Returns the root node for exposed properties for the GUI - */ - juce::ValueTree getPropertyRoot() const override; + MagicProcessorState (juce::AudioProcessor& processorToUse); /** Returns the IDs of AudioProcessorParameters for selection @@ -106,10 +100,15 @@ class MagicProcessorState : public MagicGUIState, */ void setStateInformation (const void* data, int sizeInBytes, juce::AudioProcessorEditor* editor = nullptr); + /** + Returns a parameter for a parameter ID + */ juce::RangedAudioParameter* getParameter (const juce::String& paramID) override; - std::unique_ptr createAttachment (const juce::String& paramID, juce::Slider& slider) override; - std::unique_ptr createAttachment (const juce::String& paramID, juce::ComboBox& combobox) override; - std::unique_ptr createAttachment (const juce::String& paramID, juce::Button& button) override; + void updateParameterMap(); + + std::unique_ptr createAttachment (const juce::String& paramID, juce::Slider& slider) override; + std::unique_ptr createAttachment (const juce::String& paramID, juce::ComboBox& combobox) override; + std::unique_ptr createAttachment (const juce::String& paramID, juce::Button& button) override; /** This override creates the ValueTree defining the GuiItems from the getParameterTree() @@ -117,7 +116,6 @@ class MagicProcessorState : public MagicGUIState, juce::ValueTree createDefaultGUITree() const override; juce::AudioProcessor* getProcessor() override; - juce::AudioProcessorValueTreeState& getValueTreeState(); /** Send the midi data to the keyboard and to the MidiLearn mapper. @@ -128,8 +126,14 @@ class MagicProcessorState : public MagicGUIState, */ void processMidiBuffer (juce::MidiBuffer& buffer, int numSamples, bool injectIndirectEvents=true); + /** + Connects a midi controller CC to a parameter for MIDI learn + */ void mapMidiController (int cc, const juce::String& parameterID); + /** + Returns the last moved controller for MIDI learn + */ int getLastController() const; private: @@ -144,9 +148,9 @@ class MagicProcessorState : public MagicGUIState, void timerCallback() override; juce::AudioProcessor& processor; - juce::AudioProcessorValueTreeState& state; - MidiParameterMapper midiMapper; + ParameterManager parameters { processor }; + MidiParameterMapper midiMapper { *this }; std::atomic bpm; std::atomic timeSigNumerator; diff --git a/General/foleys_MidiParameterMapper.cpp b/State/foleys_MidiParameterMapper.cpp similarity index 94% rename from General/foleys_MidiParameterMapper.cpp rename to State/foleys_MidiParameterMapper.cpp index 261c558d..efee7866 100644 --- a/General/foleys_MidiParameterMapper.cpp +++ b/State/foleys_MidiParameterMapper.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -44,7 +44,7 @@ namespace IDs static juce::String cc { "cc" }; } -MidiParameterMapper::MidiParameterMapper() +MidiParameterMapper::MidiParameterMapper (MagicProcessorState& s) : state (s) { settings->settings.addListener (this); } @@ -133,16 +133,8 @@ int MidiParameterMapper::getLastController() const return lastController.load(); } -void MidiParameterMapper::setAudioProcessorValueTreeState (juce::AudioProcessorValueTreeState* state) -{ - treeState = state; -} - void MidiParameterMapper::recreateMidiMapper() { - if (treeState == nullptr) - return; - auto mappings = settings->settings.getChildWithName (IDs::mappings); if (! mappings.isValid()) return; @@ -156,7 +148,7 @@ void MidiParameterMapper::recreateMidiMapper() if (ccNum < 1 || paramID.isEmpty()) continue; - auto* parameter = treeState->getParameter (paramID); + auto* parameter = state.getParameter (paramID); if (parameter == nullptr) continue; diff --git a/General/foleys_MidiParameterMapper.h b/State/foleys_MidiParameterMapper.h similarity index 86% rename from General/foleys_MidiParameterMapper.h rename to State/foleys_MidiParameterMapper.h index 32124c01..5a79ef19 100644 --- a/General/foleys_MidiParameterMapper.h +++ b/State/foleys_MidiParameterMapper.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -45,7 +45,7 @@ namespace foleys class MidiParameterMapper : private juce::ValueTree::Listener { public: - MidiParameterMapper(); + MidiParameterMapper (MagicProcessorState& state); ~MidiParameterMapper() override; void processMidiBuffer (juce::MidiBuffer& buffer); @@ -56,8 +56,6 @@ class MidiParameterMapper : private juce::ValueTree::Listener int getLastController() const; - void setAudioProcessorValueTreeState (juce::AudioProcessorValueTreeState* state); - private: void recreateMidiMapper(); @@ -69,12 +67,12 @@ class MidiParameterMapper : private juce::ValueTree::Listener using MidiMapping=std::map>; - SharedApplicationSettings settings; - juce::CriticalSection mappingLock; + SharedApplicationSettings settings; + juce::CriticalSection mappingLock; - juce::AudioProcessorValueTreeState* treeState = nullptr; - std::atomic lastController { -1 }; - MidiMapping midiMapper; + MagicProcessorState& state; + std::atomic lastController { -1 }; + MidiMapping midiMapper; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiParameterMapper) }; diff --git a/State/foleys_ParameterManager.cpp b/State/foleys_ParameterManager.cpp new file mode 100644 index 00000000..4a0263dd --- /dev/null +++ b/State/foleys_ParameterManager.cpp @@ -0,0 +1,114 @@ +/* + ============================================================================== + Copyright (c) 2021 Foleys Finest Audio - Daniel Walz + All rights reserved. + + License for non-commercial projects: + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + + License for commercial products: + + To sell commercial products containing this module, you are required to buy a + License from https://foleysfinest.com/developer/pluginguimagic/ + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + ============================================================================== + */ + +#pragma once + +namespace foleys +{ + +juce::Identifier ParameterManager::nodeName { "PARAM" }; +juce::Identifier ParameterManager::nodeId { "id" }; +juce::Identifier ParameterManager::nodeValue { "value" }; + + +ParameterManager::ParameterManager (juce::AudioProcessor& p) + : processor (p) +{ + updateParameterMap(); +} + +juce::RangedAudioParameter* ParameterManager::getParameter (const juce::String& paramID) +{ + auto p = parameterLookup.find (paramID); + if (p != parameterLookup.end()) + return p->second; + + return nullptr; +} + +void ParameterManager::updateParameterMap() +{ + for (auto* parameter : processor.getParameters()) + if (auto* withID = dynamic_cast(parameter)) + parameterLookup [withID->paramID] = withID; +} + +juce::StringArray ParameterManager::getParameterNames() const +{ + juce::StringArray names; + for (auto& parameter : parameterLookup) + names.add (parameter.second->paramID); + + return names; +} + +void ParameterManager::saveParameterValues (juce::ValueTree& tree) +{ + updateParameterMap(); + + for (auto& parameter : parameterLookup) + { + auto node = tree.getChildWithProperty (nodeId, parameter.first); + if (node.isValid()) + node.setProperty (nodeValue, parameter.second->convertFrom0to1 (parameter.second->getValue()), nullptr); + else + tree.appendChild ({ nodeName, { + { nodeId, parameter.second->paramID }, + { nodeValue, parameter.second->convertFrom0to1 (parameter.second->getValue()) }}}, nullptr); + } +} + +void ParameterManager::loadParameterValues (juce::ValueTree& tree) +{ + updateParameterMap(); + + for (const auto& child : tree) + { + if (child.getType() == nodeName) + { + if (! (child.hasProperty (nodeId) && child.hasProperty (nodeValue))) + continue; + + auto paramID = child.getProperty (nodeId).toString(); + if (auto* parameter = getParameter (paramID)) + parameter->setValueNotifyingHost (parameter->convertTo0to1 (child.getProperty (nodeValue))); + } + } +} + + + +} // namespace foleys diff --git a/State/foleys_ParameterManager.h b/State/foleys_ParameterManager.h new file mode 100644 index 00000000..3672d21b --- /dev/null +++ b/State/foleys_ParameterManager.h @@ -0,0 +1,69 @@ +/* + ============================================================================== + Copyright (c) 2021 Foleys Finest Audio - Daniel Walz + All rights reserved. + + License for non-commercial projects: + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + + License for commercial products: + + To sell commercial products containing this module, you are required to buy a + License from https://foleysfinest.com/developer/pluginguimagic/ + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + ============================================================================== + */ + +#pragma once + +namespace foleys +{ + +class ParameterManager +{ +public: + ParameterManager (juce::AudioProcessor& processor); + + juce::RangedAudioParameter* getParameter (const juce::String& paramID); + + juce::StringArray getParameterNames() const; + + void updateParameterMap(); + + void saveParameterValues (juce::ValueTree& tree); + + void loadParameterValues (juce::ValueTree& tree); + + static juce::Identifier nodeName; + static juce::Identifier nodeId; + static juce::Identifier nodeValue; + +private: + juce::AudioProcessor& processor; + + std::map parameterLookup; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ParameterManager) +}; + +} // namespace foleys diff --git a/VERSION.md b/VERSION.md index c8c02e72..7913c948 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1,22 +1,38 @@ PluginGuiMagic - Versions history ================================ -1.2.7 ------ +1.3.0 - 28.02.2021 +------------------ + +Breaking Changes: +----------------- + +- The GUI ValueTree is now in MagicGUIState +- AudioProcessorValueTreeState is no longer needed and not supplied to the MagicProcessorState +- Added MagicProcessor that takes care of the necessary boilerplate +- addBackgroundProcessing() is no longer necessary + +- Set TextButton to toggle when a parameter is connected +- Make it work without AudioProcessorValueTreeState +- ApplicationSettings update now when the file changes / work cross multiple plugins +- Fixed a crash with ListBox + +1.2.7 - 03.12.2020 +------------------ - Implemented margin and padding with different values on each edge - Averted an assert in DropShadow with Sliders (or Components in General) becoming only one pixel - Added option to XY-Dragger for radius and sensitivity -1.2.6 ------ +1.2.6 - 06.11.2020 +------------------ - Added Midi-Learn component to be dragged on knobs/controls - Fixed missing text property for ToggleButton -1.2.5 ------ +1.2.5 - 15.10.2020 +------------------ - Added editor for gradients, new gradients support stop positions - Refactored gradient drawing diff --git a/Visualisers/foleys_MagicAnalyser.cpp b/Visualisers/foleys_MagicAnalyser.cpp index 9bc9bd29..797c4c29 100644 --- a/Visualisers/foleys_MagicAnalyser.cpp +++ b/Visualisers/foleys_MagicAnalyser.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Visualisers/foleys_MagicAnalyser.h b/Visualisers/foleys_MagicAnalyser.h index 4e58be31..b8bcee9b 100644 --- a/Visualisers/foleys_MagicAnalyser.h +++ b/Visualisers/foleys_MagicAnalyser.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Visualisers/foleys_MagicFilterPlot.cpp b/Visualisers/foleys_MagicFilterPlot.cpp index 6bc4df58..2b03ae13 100644 --- a/Visualisers/foleys_MagicFilterPlot.cpp +++ b/Visualisers/foleys_MagicFilterPlot.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Visualisers/foleys_MagicFilterPlot.h b/Visualisers/foleys_MagicFilterPlot.h index 12d5eb9c..2c386871 100644 --- a/Visualisers/foleys_MagicFilterPlot.h +++ b/Visualisers/foleys_MagicFilterPlot.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Visualisers/foleys_MagicLevelSource.cpp b/Visualisers/foleys_MagicLevelSource.cpp index 2ef7a48c..a09d1a5a 100644 --- a/Visualisers/foleys_MagicLevelSource.cpp +++ b/Visualisers/foleys_MagicLevelSource.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Visualisers/foleys_MagicLevelSource.h b/Visualisers/foleys_MagicLevelSource.h index 5dd0597b..0133167b 100644 --- a/Visualisers/foleys_MagicLevelSource.h +++ b/Visualisers/foleys_MagicLevelSource.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Visualisers/foleys_MagicOscilloscope.cpp b/Visualisers/foleys_MagicOscilloscope.cpp index 08d1219d..b2818522 100644 --- a/Visualisers/foleys_MagicOscilloscope.cpp +++ b/Visualisers/foleys_MagicOscilloscope.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Visualisers/foleys_MagicOscilloscope.h b/Visualisers/foleys_MagicOscilloscope.h index 7e1e3290..12d8b62c 100644 --- a/Visualisers/foleys_MagicOscilloscope.h +++ b/Visualisers/foleys_MagicOscilloscope.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Visualisers/foleys_MagicPlotSource.h b/Visualisers/foleys_MagicPlotSource.h index 82ed746f..02681d99 100644 --- a/Visualisers/foleys_MagicPlotSource.h +++ b/Visualisers/foleys_MagicPlotSource.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_AutoOrientationSlider.h b/Widgets/foleys_AutoOrientationSlider.h index 79a36088..034b7894 100644 --- a/Widgets/foleys_AutoOrientationSlider.h +++ b/Widgets/foleys_AutoOrientationSlider.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_FileBrowserDialog.cpp b/Widgets/foleys_FileBrowserDialog.cpp index 4b05e56d..0a70ce40 100644 --- a/Widgets/foleys_FileBrowserDialog.cpp +++ b/Widgets/foleys_FileBrowserDialog.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_FileBrowserDialog.h b/Widgets/foleys_FileBrowserDialog.h index 9c50fb97..3d45c165 100644 --- a/Widgets/foleys_FileBrowserDialog.h +++ b/Widgets/foleys_FileBrowserDialog.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_MagicLevelMeter.cpp b/Widgets/foleys_MagicLevelMeter.cpp index bf6bfaa2..7bb59420 100644 --- a/Widgets/foleys_MagicLevelMeter.cpp +++ b/Widgets/foleys_MagicLevelMeter.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_MagicLevelMeter.h b/Widgets/foleys_MagicLevelMeter.h index f4f75838..b71cacd5 100644 --- a/Widgets/foleys_MagicLevelMeter.h +++ b/Widgets/foleys_MagicLevelMeter.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_MagicPlotComponent.cpp b/Widgets/foleys_MagicPlotComponent.cpp index 9efb5a5b..2178699d 100644 --- a/Widgets/foleys_MagicPlotComponent.cpp +++ b/Widgets/foleys_MagicPlotComponent.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_MagicPlotComponent.h b/Widgets/foleys_MagicPlotComponent.h index 6246da3a..30a5acbd 100644 --- a/Widgets/foleys_MagicPlotComponent.h +++ b/Widgets/foleys_MagicPlotComponent.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_MidiLearnComponent.cpp b/Widgets/foleys_MidiLearnComponent.cpp index ab06b55d..223ee6fb 100644 --- a/Widgets/foleys_MidiLearnComponent.cpp +++ b/Widgets/foleys_MidiLearnComponent.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_MidiLearnComponent.h b/Widgets/foleys_MidiLearnComponent.h index b9851eec..cb54fb3c 100644 --- a/Widgets/foleys_MidiLearnComponent.h +++ b/Widgets/foleys_MidiLearnComponent.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_XYDragComponent.cpp b/Widgets/foleys_XYDragComponent.cpp index e60c8668..70ec3699 100644 --- a/Widgets/foleys_XYDragComponent.cpp +++ b/Widgets/foleys_XYDragComponent.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/Widgets/foleys_XYDragComponent.h b/Widgets/foleys_XYDragComponent.h index d617b49c..8f0a19c2 100644 --- a/Widgets/foleys_XYDragComponent.h +++ b/Widgets/foleys_XYDragComponent.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: diff --git a/foleys_gui_magic.cpp b/foleys_gui_magic.cpp index d7c97674..3d7337e3 100644 --- a/foleys_gui_magic.cpp +++ b/foleys_gui_magic.cpp @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -46,11 +46,14 @@ #include "General/foleys_ApplicationSettings.cpp" #include "General/foleys_MagicGUIBuilder.cpp" #include "General/foleys_MagicPluginEditor.cpp" -#include "General/foleys_MagicGUIState.cpp" -#include "General/foleys_MagicProcessorState.cpp" +#include "General/foleys_MagicProcessor.cpp" #include "General/foleys_Resources.cpp" #include "General/foleys_MagicJUCEFactories.cpp" -#include "General/foleys_MidiParameterMapper.cpp" + +#include "State/foleys_MagicGUIState.cpp" +#include "State/foleys_MagicProcessorState.cpp" +#include "State/foleys_ParameterManager.cpp" +#include "State/foleys_MidiParameterMapper.cpp" #include "Layout/foleys_GradientBackground.cpp" #include "Layout/foleys_Stylesheet.cpp" diff --git a/foleys_gui_magic.h b/foleys_gui_magic.h index 61a9214a..0e0e964b 100644 --- a/foleys_gui_magic.h +++ b/foleys_gui_magic.h @@ -1,6 +1,6 @@ /* ============================================================================== - Copyright (c) 2019-2020 Foleys Finest Audio Ltd. - Daniel Walz + Copyright (c) 2019-2021 Foleys Finest Audio - Daniel Walz All rights reserved. License for non-commercial projects: @@ -36,12 +36,13 @@ BEGIN_JUCE_MODULE_DECLARATION ID: foleys_gui_magic - vendor: Foleys Finest Audio Ltd. - version: 1.2.6 + vendor: Foleys Finest Audio + version: 1.3.0 name: Foleys GUI magic description: This module allows to create GUI with a drag and drop editor dependencies: juce_core, juce_audio_basics, juce_audio_devices, juce_audio_formats, - juce_audio_utils, juce_audio_processors, juce_gui_basics, juce_dsp + juce_audio_utils, juce_audio_processors, juce_gui_basics, juce_dsp, + juce_cryptography website: https://foleysfinest.com/ license: Dual license: non commercial under BSD V2 3-clause @@ -83,6 +84,7 @@ #include #include #include +#include #include #if JUCE_MODULE_AVAILABLE_juce_opengl && FOLEYS_ENABLE_OPEN_GL_CONTEXT @@ -154,8 +156,11 @@ namespace EditorColours #endif // FOLEYS_SHOW_GUI_EDITOR_PALLETTE -#include "General/foleys_MidiParameterMapper.h" -#include "General/foleys_MagicGUIState.h" -#include "General/foleys_MagicProcessorState.h" +#include "State/foleys_ParameterManager.h" +#include "State/foleys_MidiParameterMapper.h" +#include "State/foleys_MagicGUIState.h" +#include "State/foleys_MagicProcessorState.h" + #include "General/foleys_MagicGUIBuilder.h" #include "General/foleys_MagicPluginEditor.h" +#include "General/foleys_MagicProcessor.h"