here is how i implement my params
// PluginProcessor.h
public:
juce::AudioProcessorValueTreeState::ParameterLayout exampleParameterLayout();
juce::AudioProcessorValueTreeState apvts{ *this, nullptr, "Parameters", exampleParameterLayout() };
for the layout itself
// PluginProcessor.cpp
juce::AudioProcessorValueTreeState::ParameterLayout *your processor classname* exampleParameterLayout()
{
juce::AudioProcessorValueTreeState::ParameterLayout layout;
juce::StringArray stringArray;
stringArray.add("choice a");
stringArray.add("choice b");
stringArray.add("choice c");
// for float values
layout.add
(std::make_unique<juce::AudioParameterFloat>("ID_Float", "Float", juce::NormalisableRange<float>(-60.f, 60.f, 0.01f), 0.f));
// for choice values
layout.add
(std::make_unique<juce::AudioParameterChoice>("ID_Choice", "Choices", stringArray, 0));
return layout;
}
now, how do you update the GUI according to the parameter changes?
// PluginEditor.h
private:
juce::Slider sliderX;
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> attachmentX;
in your editor
// PluginEditor.cpp -- Constructor
addAndMakeVisible(sliderX);
attachmentX.reset(new juce::AudioProcessorValueTreeState::SliderAttachment{ audioProcessor.apvts, "ID_Float", sliderX });
// PluginEditor.cpp -- Destructor
attachmentX.reset(nullptr);
then obviously you
sliderX.setBounds(x, y, width, height);
in your resized() function.
for updating the parameters, go to your processor.cpp processBlock
// AudioProcessor.cpp
void *classname*::processBlock
// place this under the code that clears your buffer
auto myFloat = apvts.getRawParameterValue("ID_Float")->load();
// do your processing here