Plugin architecture

An audio plug-in, made with JUCE consists of several folders and files. However, the main stuff will happen within two files: The PluginProcessor and the PluginEditor. The "PluginProcessor" will process the audio while the "PluginEditor" will handle the GUI. We will take a closer look later in this file.

General structure

Every audio plug-in, made with JUCE will have the following folders:

YourAudioPlugin
|-Source
  |-PluginEditor.cpp
  |-PluginEditor.h
  |-PluginProcessor.cpp
  |-PluginEditor.h
|-Builds
|-Juce Library Code

The Source-folder holds the source code of the JUCE application. The GUI is defined here, aswell as the audio processing stuff.

The Builds-folder holds the export targets generated by the "Projucer". The generated binaries will also be exported to some subfolder here.

Lastly, the folder JuceLibraryCode holds autogenerated files, that are essential to include the JUCE modules. Those will be deleted and completely re-written whenever the Projucer saves your project. You really should't change anything here since it just will get deleted.

Since most of the work is done in the Source-folder, we should take a closer look to the files inside.

PluginProcessor

In a JUCE audio plug-in, the PluginProcessor is the core engine that handles all audio processing, parameter management and plugin state. It is where your plugin actually does the sound-related work.

You're going to write a lot of code in some functions and in some, you maybe don't need to write that much code. Here are the most used classes within "PluginProcessor":

  • prepareToPlay(): Initialization happen here. This will get called right before the audio is being processed.
  • processBlock(): Here you will manipulate the audio in real time.
  • releaseRessources(): When playback stops, you can use this as an opportunity to free up any spare memory, etc.
  • getStateInformation(): This will load the state of the plug-in.
  • setStateInformation(): This will save the state of the plug-in.
  • createEditor(): This will create the window for the plug-in.

Note: The "state" of the plugin is just in what state the parameters of the plugin are.

PluginEditor

In a JUCE audio plug-in, the "PluginEditor" is the graphical user interface (GUI) that allows users to interact with your plugin. It displays sliders, buttons, meters, and other controls, and connects them to the audio processing happening in the "PluginProcessor".

Here, you will build your interface and decide how users will interact with your parameters. Sometimes there are just few sliders, sometimes it's a whole custom visual environment.

Here are the classes within "PluginEditor":

  • paint(): This is where you draw any custom graphics or backgrounds.
  • resized(): Called when the editor changes size.