Welcome back for part 5 of this tutorial series! Last time we did some very simple audio processing to produce saturation in our plugin.  Today we will be adding a slider which will later be used to control the amount of saturation that is applied to the signal.

Header File

Lucky for us, JUCE has some very useful classes to help us out. Open up the PluginEditor.h file and add the following bits of code.

PluginEditor.h

  1. We need to create a pointer to a Slider object. Sliders have loads of methods and are very easy to implement.
  2. In order for this changes in the Slider’s values to be detected, the Editor needs to inherit from SliderListener.
  3. SliderListener is an abstract class. It has the virtual method sliderValueChanged() which must be overridden. This method will be called every time any slider value is changed.

Now we will take a look at PluginEditor.cpp for the implementation of these objects and methods.

The Constructor

constructor

In the editor’s constructor, will will need to add just three lines of code for now.

  1. Any time we want to add a GUI component to the editor, we must call addAndMakeVisible(). Inside the method call, we are also creating a new Slider() object and assigning it to the amountSlider pointer.  These two task can be done separately but, it looks nicer this way.
  2. We will want to set a range for the amount slider, which we can do using it’s setRange() method. The first parameter is the lowest possible value, the second parameter is the highest possible value, and the third parameter, is interval in which the slider will move.
  3. The slider also needs to be able to be detected by the Editor’s SliderListener. We can do this by calling addListener(this). We use this because we want the listener of the Editor and not some other listener.

Resized

void resized() is where we want to layout the position of all of our GUI components. All we need to do is call the setBounds(x, y, width, height) method of the slider as shown below.

void Resized()

Detecting Changes in Slider Values

The final part of this tutorial will be implementing the SliderListener.

sliderValueChanged

If you want, you can simply copy what is in the picture above, however, it is important to know what the method does.  sliderValueChanged() has a Slider pointer. When the method is called, the pointer will point to the Slider that was changed.  This means we can check which slider was changed by using a simple if statement like you see above.  Inside the if statement is where we will change parameter values and do other sorts of things, but we will save that for the next tutorial!

If you build the plugin and load it up in your host, it should look similar to this.

built

In the next tutorial we will cover how to use paramaters, until then I want to challenge you to add a second Slider which we will later use to control the gain. As always, thanks for reading, and if you have any questions, just leave a comment or a post in the forum!

Sign up for our newsletter so you dont miss new deals and anouncements!

Please follow and like us:
Categories: AudioJUCEProgramming

6 Comments

Matt · May 10, 2016 at 4:45 pm

Are you planning on continuing those tutorials?

    abaga129

    abaga129 · May 10, 2016 at 6:57 pm

    Yeah I definitely will continue these tutorials. I got busy with finals coming up, but I should be posting the one about using parameters within the next week. Sorry its taking so long.

Peter · May 19, 2016 at 7:57 am

Man! This is great! 🙂 just heads up – please continue and thanks a lot for your work and sharing! 😉

    abaga129

    abaga129 · May 23, 2016 at 6:49 pm

    Im glad that you are finding these tutorials useful! I apologize that it is taking so long for the next one, but dont worry I havent forgotten! I have several planned, i just have to find the time to write them.

Peter · May 19, 2016 at 10:10 am

I just completed this tutorial. everything went fine and ok, however there is no way how to display the plugin in my DAW – it’s just not recognized ..I tried everything (rescan plugins, tried 32, x64 build + 32/64 DAW) absolutely no idea why) Any ideas?

Peter · May 19, 2016 at 11:15 am

pls disregard my las comment – I am lamma – tried to run the plugin on PC w/o vS++2015 update 😉

Cannot wait for next chapter!

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Audio

EpicPRESS – Coming Soon!

Keep an eye out for our newest plugin EpicPRESS which will be released by January 1st 2017!  EpicPRESS is a stereo compressor with all of the controls you would expect: threshold, attack, release, ratio, knee, Read more…

Audio

Entropy II Released – VST and AU Plug-in

If you have been using Entropy and enjoy it’s features then I have good news for you.  Entropy II is out!  This version adds many new features such as tempo syncing, feedback filtering, and saturation.  Read more…

Audio

M4 Is Released – VST & AU Plug-in

M4 is finally finished and can now be purchased by heading over to our products page here! http://www.modernmetalproduction.com/products/ If you didn’t see our previous post, let me fill you in. M4 is a Multiband Compressor Read more…