Sliders not working on Overdrive plugin

Hi I’m really new to coding but I am trying to create an overdrive plugin with an input and output gain slider control but whenever I build it, the input and output sliders are stuck at either end and nothing changes with the audio. Any help or suggestions to where I may be going wrong would be really appreciated and apologies for any stupid mistakes.

The input/output sliders where declared in the editor .cpp here:

//Input Slider Porperties
InputSlider.setRange(1, 10.0);
InputSlider.setTextValueSuffix(" dB");
InputSlider.addListener (this);
//makes slider logorythmic

//Input Slider Label
InputLabel.setText ("Input", juce::dontSendNotification);
InputLabel.attachToComponent(&InputSlider, true);

//Output Slider Porperties
OutputSlider.setRange(1, 100.0);
OutputSlider.setTextValueSuffix(" dB");
OutputSlider.addListener (this);
//Makes slider logarithmic

//Output Slider Label
OutputLabel.setText ("Output", juce::dontSendNotification);
OutputLabel.attachToComponent(&OutputSlider, true);

In the editor header file here:

OverdriveAudioProcessorEditor (OverdriveAudioProcessor&);

void paint (Graphics&) override;
void resized() override
    auto sliderLeft = 120;
    InputSlider.setBounds (sliderLeft, 100 , getWidth() - sliderLeft - 10, 20);
    OutputSlider.setBounds (sliderLeft, 150, getWidth() - sliderLeft - 10, 20);

void sliderValueChanged (Slider *slider) override;
void timerCallback() override;

OverdriveAudioProcessor& processor;
Slider threshSlider;

juce::Slider InputSlider;
juce::Label InputLabel;
juce::Slider OutputSlider;
juce::Label OutputLabel;

In the processor header:

// declare slider parameter objects below
AudioParameterFloat *threshParam;
AudioParameterFloat *InputParam;
AudioParameterFloat *OutputParam;

And in the processor .cpp:

// apply processsing to each channel…
for (int channel = 0; channel < totalNumInputChannels; ++channel)
float* channelData = buffer.getWritePointer (channel);
for(int sampleNum=0; sampleNum<buffer.getNumSamples(); sampleNum++)
channelData[sampleNum] = channelData[sampleNum]*input;

        if(channelData[sampleNum] > *threshParam)
            channelData[sampleNum] = *threshParam;
        else if (channelData[sampleNum] < -*threshParam)
            channelData[sampleNum] = -*threshParam;

        channelData[sampleNum] = channelData[sampleNum]*output;

I also have a threshold slider within the plugin which is working correctly which is why I have threshParam

hi and welcome to the journey!

The whole system of attaching audio parameters to GUI widgets is somewhat complex and has a few moving parts.

but the system always works like this in JUCE:

void YourAudioProcessor::processBlock(...)
    //cache your parameter's value at the start of processBlock()
    auto cachedValue = apvts.getParameter("the parameter name")->getValue();
    //update your dsp model with the cached value

    //now perform the DSP processing
   for( every sample )
       for( each channel )
          dsp.process(channel, sample);

obviously this is pseudo code, but it shows the pattern.

Your AudioProcessor needs an instance of the juce::AudioProcessorValueTreeState, and it needs to be public. Alternatively you can provide a public getter function that returns it by reference.

On the GUI side of things, you need to use ParameterAttachments to connect your GUI widget with the appropriate audio parameter.

class PluginEditor : ...
    PluginEditor(YourAudioProcessor& p) : 
    YourAudioProcessor& processor;
    using APVTS = AudioProcessorValueTreeState;
    APVTS& apvts { processor.apvts };
    Slider slider;
    APVTS::SliderAttachment sliderAttachment { *apvts.getParameter("the parameter name"), 
                                               nullptr };

If you haven’t gone through all of the tutorials on the JUCE site, you should.

Alternatively, you can go through my tutorial from the FreeCodeCamp YT channel which will show you how to connect all of your DSP to your parameters, and how to connect all of those parameters to your GUI widgets using juce::APVTS, the APVTS::Attachment classes, as well as customize the graphics. All of the techniques in the video and in the JUCE tutorials will apply to any plugin that you work on, including this Overdrive plugin.

Hey @matkatmusic I really appreciate your help, got through the distortion plug in and have really enjoyed getting more in depth with coding.

I started working through an EQ plugin from your YouTube video and loved the detailed yet not rushed explanation, im really getting more confident with coding.

However, I am struggling with an issue that keeps popping up where I am declaring the Parameters and getting an error saying “No matching constructor for initialisation of AudioParameterFloat”. I have tried my best to follow the tutorial as close as possible to figure it out but unfortunately can’t.

Do you possibly know why this error is occurring? Below is the code, minimised. Any help would be massively appreciated as id really like to get more creative with audio plugins.

juce::AudioProcessorValueTreeState::ParameterLayout layout;
layout.add(std::make_uniquejuce::AudioParameterFloat(“LowCut Freq”,
“LowCut Freq”,
juce::NormalisableRange(20.f, 20000.f, 1.f, 1.f, 20.f)));

juce::StringArray stringArray;
for( int i = 0; i < 4; ++i)
juce::String str;
str << (12 + i*12);
str << “dB/Oct”;

layout.add(std::make_unique<juce::AudioParameterChoice>("LowCut Slope", "LowCut Slope", stringArray, 0));
layout.add(std::make_unique<juce::AudioParameterChoice>("HighCut Slope", "HighCut Slope", stringArray, 0));

return layout;


That constructor requires specific values passed in a specific order to it. You are not doing that in the argument list you’re passing to std::make_unique.

That is what that error message means.

Consult the documentation of AudioParameterFloat to see what values it wants passed to it.

If you want more direct help then just grab the course from my website ( it’s free ) and message me in the slack workspace. The email with an invite link will be sent as soon as you sign up. PFM::SimpleEQ – Matkat Music