I am new to JUCE as well as PGM, and not too familiar with C++, so quite a combination. Still I made gradual progress following the videos and looking at PGM examples, JUCE tutorials etc. However I am struggling to connect parameters in my plugin to the GUI controls. In the PGM youtube videos made by Daniel, the interface is already populated with parameters from the plugin, and in some of the example code, the JUCE parameters are explicitly coded.
I have probably made a mistake by creating the controls I want before coding the parameters. What I am really looking for is a very simplistic tutorial or example for the case of e.g. creating a float parameter (say gain) and then connecting that to GUI that works with the latest version of PGM. But failing that could someone give an outline of the steps that would be involved?
Say I have defined a slider using the PGM tools, and I have a blank JUCE plugin project with PluginProcessor.cpp and PluginProcessor.h. How would I add a gain parameter and connect it to the slider?
The answer for novices like me is:
i) set up the projucer project with foleys_gui_magic module as explained here:
ii) add a line like this to your PluginProcessor.h file:
juce::AudioParameterFloat* gain;
iii) add a line like this to your PluginProcessor.cpp file:
addParameter(gain = new juce::AudioParameterFloat(“gain”,“Gain”,0.0f,1.0f,0.5f));
iv) when you build and run the project PGM will already find your parameter and link it to a slider. If you already created a control, you will find the gain parameter listed as one of those you can link to it.
I had missed the addParameter call in the constructor and just tried to declare and initialize the parameter variable. But JUCE and PGM provide methods to add parameters which are inherited from AudioProcessor (or MagicProcessor):
I am glad you found a solution.
PGM is able to pick up parameters added in any way juce allows. You can call addParameter or use the AudioProcessorValueTreeState.