In this next part of the tutorial, we will be going over the basics of the JUCE Framework and looking at some of it’s methods. To begin, navigate to your source code in Visual Studio’s Solution Explorer If you don’t see the solution explorer on the right side of the screen, go to the View tab and select Solution Explorer.
JUCE Audio Processor Basics
Double click the file PluginProcessor.cpp to open it. This file is where all of our audio processing will be done. More specifically, scroll down through the method implementations until you see void SimpleSaturatorAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) This method is where all of the dsp (digital signal processing) will happen. In other words, anything that changes the sound of the audio will be done here.
As the above picture shows, JUCE already has some very useful pseudo-code written for us.
- This loop clears out any garbage left in the output channel to prevent anything unexpected.
- This loop is used to iterate through each audio channel. Instead of processing each channel separately, this allows us to write the code once and have it apply to each channel.
Look at the following line inside the loop
float* channelData = buffer.getWritePointer (channel);
This statement assigns a pointer to current sample for the current channel. Now you can manipulate that sample to change the sound. This method is called over and over as long as there are audio samples in the buffer. In the next tutorial I will show you how to manipulate the samples.
JUCE Audio Processor Editor Basics
Now we will move on and introduce the Audio Processor Editor. This part of the plug-in is where anything GUI(Graphical User Interface) related is done. Open the file PluginEditor.cpp This file is not nearly as large because there are only four methods.
- The constructor: This is where we will initialize any variables and set images later on.
- The destructor: Used to clean up memory when the editor is destroyed.
- Paint: This is where we will call the paint methods for our various components (knobs, sliders, buttons, images, etc.)
- Resized: All of the bounds of our components should be set in this method.
If you look at the paint method you will see that there is already some code using the Graphics object g that creates a background and draws some text to the screen.
g.drawFittedText (“Hello World!”, getLocalBounds(), Justification::centred, 1);
We will discuss the Plugin Editor in more detail in later tutorials, but feel free to play around with some of these values and see how it affects the plugin’s GUI.
The Header Files
As you probably already know, the header files PluginProcessor.h and PluginEditor.h will be used to declare variables and methods. We wont do much with these files.
Now that we have a very basic overview of the files while will be working with, in the next tutorial we will start actually processing audio!
Subscribe here to be notified of new posts!