New way to use PGM in plugins

Since Version 1.3.0 there is an easier way to use PluginGuiMagic in a JUCE based plugin.

What stays the same is to add the foleys_gui_magic to the project.

  • Instead of inheriting juce::AudioProcessor inherit foleys::MagicProcessor
  • You don’t need to add a magicState. It is alreadt added in the new base class
  • You don’t need to use AudioProcessorValueTree, but you can.
  • You need to remove the hasEditor and createEditor from your processor class, so the editor is created from the base class
  • You should remove setStateInformation/getStateInformation to enable a preconfigured loading and saving of your plugins state
  • to add your own components override the void initialiseBuilder (foleys::MagicBuilder& builder):
void MyProcessor::initialiseBuilder (MagicGUIBuilder& builder)
{
    builder.registerJUCEFactories();
    builder.registerJUCELookAndFeels();
    // add your own factories here:
    builder.registerFactory ("MyComponent", &MyComponenttem::factory);
    // the factory was created by adding the FOLEYS_DECLARE_GUI_FACTORY (MyComponentItem) to your wrapping GuiItem
}

This is how you set up the GUI in your processors constructor:

  • set the ValueTree in the constructor from BinaryData:
magicState.setGuiValueTree (BinaryData::magic_xml, BinaryData::magic_xmlSize);
  • Alternatively you can load from a file. On Mac it is particularily useful, since you can change it without recompiling. This uses the file and falls back to a version in BinaryData:
auto file = juce::File::getSpecialLocation (juce::File::currentApplicationFile)
        .getChildFile ("Contents")
        .getChildFile ("Resources")
        .getChildFile ("magic.xml");

if (file.existsAsFile())
    magicState.setGuiValueTree (file);
else
    magicState.setGuiValueTree (BinaryData::magic_xml, BinaryData::magic_xmlSize);
  • Last but not least you can use an auto generated ValueTree, which adds as many controls as it knows about:
auto defaultGUI = magicState.createDefaultGUITree();
magicState.setGuiValueTree (defaultGUI);

Hope that helps, please let me know if there are problems

1 Like