AudioProcessorValueTreeState Slider Attachment problem

I’m working on an EQ Audio Plugin and when I link the parameters created in the apvts with the Sliders and run the program I get an error.
These are my sliders, which came from a struct to group them easily:

struct CustomRotarySlider : juce::Slider
CustomRotarySlider() : juce::Slider(juce::Slider::SliderStyle::RotaryHorizontalVerticalDrag,
CustomRotarySlider peakFreakSlider, peakGainSlider, peakQualitySlider, lowCutFreqSlider, highCutFreqSlider, lowCutSlopeSlider, highCutSlopeSlider;

I also wrote the attachment in the declaration of PluginEditor.h

std::unique_ptr< juce::AudioProcessorValueTreeState::SliderAttachment > peakGainSliderAttachment;
std::unique_ptr< juce::AudioProcessorValueTreeState::SliderAttachment > peakFreakSliderAttachment;
std::unique_ptr< juce::AudioProcessorValueTreeState::SliderAttachment> peakQualitySliderAttachment;
std::unique_ptr< juce::AudioProcessorValueTreeState::SliderAttachment > lowCutFreqSliderAttachment;
std::unique_ptr< juce::AudioProcessorValueTreeState::SliderAttachment > highCutFreqSliderAttachment;
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment > lowCutSlopeSliderAttachment;
std::unique_ptr< juce::AudioProcessorValueTreeState::SliderAttachment > highCutSlopeSliderAttachment;

In the constructor of PluginEditor.cpp I linked every parameter ID from the apvts layout with the actual slider:

peakFreakSliderAttachment = std::make_unique< juce::AudioProcessorValueTreeState::SliderAttachment>(audioProcessor.apvts, “Peak Freq”, peakFreakSlider);
peakGainSliderAttachment = std::make_unique< juce::AudioProcessorValueTreeState::SliderAttachment>(audioProcessor.apvts, “Peak Gain”, peakGainSlider);
peakQualitySliderAttachment = std::make_unique< juce::AudioProcessorValueTreeState::SliderAttachment>(audioProcessor.apvts, “Peak Quality”, peakQualitySlider);
lowCutFreqSliderAttachment = std::make_unique< juce::AudioProcessorValueTreeState::SliderAttachment>(audioProcessor.apvts, “LowCutFreq”, lowCutFreqSlider);
highCutFreqSliderAttachment = std::make_unique< juce::AudioProcessorValueTreeState::SliderAttachment>(audioProcessor.apvts, “HighCut Freq”, highCutFreqSlider);
lowCutSlopeSliderAttachment = std::make_unique< juce::AudioProcessorValueTreeState::SliderAttachment>(audioProcessor.apvts, “LowCut Slope”, lowCutSlopeSlider);
highCutSlopeSliderAttachment = std::make_unique< juce::AudioProcessorValueTreeState::SliderAttachment>(audioProcessor.apvts, “HighCut Slope”, highCutSlopeSlider);

My problem is when I run the program I get this error from a screen that says juce_AudioPrcessorValueTreeState.cpp:

Please, let me know any idea about what could be the problem. Thanks

Does “LowCutFreq” need a space like all the others have?

1 Like

What we know at this stage is, that there is no parameter with this name found, hence the jassertfalse (fall through).

For that reason and for DRY, don’t use strings in your code. If you write a string literal assume it is different from where you wrote the “same” string, because of typos, refactors etc. and the compiler cannot help you.

This is an alternative:

static constexpr auto* paramLowCutFreq = "Low Cut Freq";

lowCutFreqSliderAttachment = std::make_unique<juce::AudioProcessorValueTreeState::SliderAttachment>(audioProcessor.apvts, paramLowCutFreq, lowCutFreqSlider);


But it could be also that you didn’t add the parameter properly to the apvts, we don’t know that part of the code

1 Like

That’s true. This silly mistake was the reason for the problem. Thanks so much

All good, Daniel’s advice is spot on too, I think we all make this painfully annoying lesson early on and then we start using variables as he’s described. I like to wrap mine in a namespace, such as params::gain, params::eqBand1Freq, etc.


That’s good to know. I’ll follow Daniel’s and your advice. Thanks a lot