This tutorial will demonstrate how to create saturate: a simple, soft saturation plugin using the JUCE framework. In particular, I will focus on the following:
setting up the JUCE project
implementing the DSP code
implementing the GUI code
how to export the plugin for use inside of a Digital Audio Workstation (DAW)
This plugin is part of my open source juce plugin library. It contains the following features:
drive parameter for subtle distortion and overall warmth
crush parameter for sample rate reduction and harmonic excitement
output gain and mix parameters to shape the overall sound
Prerequisites:
Basic understanding of how to set up JUCE projects (more on that here)
Understanding of basic programming concepts (preferably in C++)
Experience with Object-oriented program design (again, preferably in C++)
Project Setup
Navigate to Projucer and create a new basic project.
Give it a name, and save the folder wherever you see fit
– I usually save it to the desktop.
Part 2 - Creating the DSP
This part will focus on the DSP component of the plugin
In your project folder, open the .jucer filer in Projucer. Begin by creating two files - Params.h and Params.cpp
Together, these files will define and implement the “Parameters” Object.
Next, copy the code for both Params.h and Params.cpp
Now, in PluginProcessor.h, include “Params.h” and in the public and private sections, add the following constant values (for the crush effect) and the Params and APVTS objects:
In PluginProcessor.cpp, we will instantiate the objects in the constructor
in the initializer list.
Set the hasEditor method to
return false (we will test the program before supplying the editor).
At this point, we can also build the program to make sure we don’t have any errors.
Lastly, we will implement the sound processing algorithm.
If you are curious about the math behind the saturation algorithm, you can take a look at this desmos graph and see the behaviour of the tanh function when drive is applied to the sound wave.
If everything was set up correctly, running the standalone version of the plugin should yield
the basic layout of our parameters:
There different ways to test audio processing in the plugin. Personally,
I use the Juce Plug-in Host alongside Audio File Player
(video tutorial).
Increasing the drive
parameter should give a progressively stronger tone of overall warmth and add extra harmonics.
Increasing the crush parameter should give “excitement” to higher range frequencies (10kHz - 20kHz).
Part 3 - Creating the Interface
This part will focus on creating the GUI of the plugin
We begin by adding two new objects to the project:
LookAndFeel
RotaryKnob
In your project folder, open the .jucer filer in Projucer and create the 4 files - LookAndFeel.h, LookAndFeel.cpp, RotaryKnob.h, and RotaryKnob.cpp
Define LookAndFeel.h and LookAndFeel.cpp in the following manner:
Next, define RotaryKnob.h and RotaryKnob.cpp in the following manner:
Now we will create our interface in the PluginEditor object. In the header file,
include the new objects and in the private section, copy the following code.
In PluginEditor.cpp, edit the following:
The constructor:
The paint function:
The resized function:
Lastly, now that we have implemented the GUI, all we have to do is
enable hasEditor to be true before running the plugin!
Part 4 - Making a Release Build for your DAW
The final step is to build a release version of the plugin, which can be used in a DAW of your choice.
Setup
NOTE FOR WINDOWS: It is recommended to use static runtime for the release build. Otherwise, you must ensure that Windows Runtime is installed on any computer that uses the plugin
(source).
Release version on Visual Studio: Change the configuration
to Release, then build the plugin.
Release version on Xcode: According to the juce forums, select the Product tab and choose Build For > Profiling, then build the plugin.
Adding the plugin to your DAW
Navigate to your project folder. From here, find the location of your release
build. For me, this is:
C:\..path to project..\distortion\Builds\VisualStudio2022\x64\Debug\VST3
At this point, there are two options to get the plugin into your DAW:
Option 1: Set your DAW to scan the path to your .vst3 file
Option 2: Place the VST3 folder in a file path that your DAW already scans
FINAL NOTE: If you are building the VST3 version of the plugin, and using FL Studio with Windows, there is a dedicated folder where you must place the plugin:
C:\Program Files\Common Files\VST3
If you made it this far, you should now be able to run the plugin in your DAW!