We are also going to add two sliders to the Plugin UI. All code in bold needs to be added. The only big difference when adding sliders is that we need to check which slider is being moved in the SliderValueChanged() function.

Be careful to copy these lines in the correct places, if you have trouble you can see the final plugin code at:

https://github.com/aRycroft/JuceTutorial3

PluginEditor.h:

class DistortionAudioProcessorEditor :

public

AudioProcessorEditor,

private

ComboBox::Listener,

Slider::Listener

private:

void comboBoxChanged(ComboBox* comboBoxThatHasChanged) override;

void sliderValueChanged(Slider* sliderThatHasChanged) override;

// This reference is provided as a quick way for your editor to

// access the processor object that created it.

DistortionAudioProcessor& processor;

ComboBox disChoice;

Slider Threshold;

Slider Mix;

PluginEditor.cpp:

{

// Make sure that before the constructor has finished, you’ve set the

// editor’s size to whatever you need it to be.

setSize (400, 300);

addAndMakeVisible(&disChoice);

disChoice.addItem(“Hard Clip”, 1);

disChoice.addItem(“Soft Clip”, 2);

disChoice.addItem(“Half-Wave Rect”, 3);

disChoice.setSelectedId(1);

disChoice.addListener(this);

addAndMakeVisible(&Threshold);

Threshold.setRange(0.0f, 1.0f, 0.001);

Threshold.addListener(this);

addAndMakeVisible(&Mix);

Mix.setRange(0.0f, 1.0f, 0.001);

Mix.addListener(this);

}

void DistortionAudioProcessorEditor::resized()

{

// This is generally where you’ll want to lay out the positions of any

// subcomponents in your editor..

disChoice.setBounds(50, 50, 200, 50);

Threshold.setBounds(50, 100, 200, 50);

Mix.setBounds(50, 150, 200, 50);

}

PluginProcesor.h:

int menuChoice;

float thresh = 0.0f;

float mix = 0.0f;