This tutorial explains how to create a new audio plug-in by using the VST 3 Project Generator included in the VST 3 SDK and how to add some basic features.
The artifact will be an audio plug-in that can compute a gain to an audio signal and can be loaded into VST3 hosts like Cubase, WaveLab, ...
Part 1: Getting and installing the VST 3 SDK
For downloading the SDK, see the section " How to set up my system for VST 3".
You have the following possibilities to start a new project:
- You can use the helloworld template included in the VST SDK and duplicate the folder into a new folder. Adapt each file where the comment mentions it.
- Or, which is easier and recommended, you can use the VST3 Project Generator application included in the VST SDK. The following steps show how to use it.
Part 2: Using the VST 3 plug-in Project Generator application
The VST3 Project Generator application included in the VST SDK is available for Windows and for macOS.
Start the application located in the VST3_Project_Generator folder of the VST SDK.
Check that the Preferences tab has the required information: see Setting the Preferences
In the Create Plug-in Project tab you have to enter information about the plug-in that you want create:
Once you have entered all information, click Create. A script is started which creates a project with updated files in the Output directory. After this step, the IDE (Visual Studio or XCode) is launched.
Compile the project and test your new plug-in. The plug-in is created in the Output Directory, in order to make it visible to a VST 3 host you may have to copy or symbolic-link it to the official VST 3 Locations / Format.
For example, if you chose Audio Effect as Type, a simple Stereo→Stereo plug-in is created.
A good way to understand how a VST 3 plug-in works is to add breakpoints in each function in the processor and controller files:
and start a VST 3 host from the debugger.
Part 3: Coding your Plug-in
Now you have an automatically generated frame for your plug-in. The following sections explain how to add a new parameter, its associated processing algorithm, and other specific features like saving/loading project or presets, creating a dedicated user interface, etc.
A VST 3 plug-in contains two main classes: its PlugProcessor (performing the processing and persistence) and its PlugController (taking care of communication with the DAW, handling parameters and the UI).
Add a parameter: Gain
In this basic plug-in example, we will add a Gain parameter which modifies the volume of the audio going through the plug-in.
For this, each VST 3 parameter requires a unique identifier (a number).
- Open the file plugids.h and enter a new id kParamGainId. In this example, assign the unique number 102.
2. Open the plugcontroller.cpp file, and add the gain parameter with the parameters.addParameter
- We add the flag kCanAutomate which informs the DAW/host that this parameter can be automated.
- A VST 3 parameter is always normalized (its value is a floating point value between [0, 1]), here its default value is set to 0.5.
3. Now adapt the processor part for this new parameter. Open the file plugprocessor.h and add a gain value Vst::ParamValue mGain. This value is used for the processing to apply the gain.
Add the process applying the gain
- We need to set our internal mGain with its required value from the host. This is the first step of the process method. Parse the parameter change coming from the host in the structure data.inputParameterChanges for the current audio block to process.
2. The real processing part:
3. VST 3 includes a way for the host to inform the plug-in that its inputs are silent (using the VST 3 silence flags):
Add store/restore state
The Processor part represents the state of the plug-in, so it is its job to implement the getState/setState method used by the host to save/load projects and presets.
- In the file plugprocessor.cpp, add the mGain value to the state stream given by the host in the getState method which will save it as a project or preset.
2. In the setState () method, the plug-in receives a new state (called after a project or preset is loaded) from the host.
Part 4: Advanced Steps
Add an Event Input
In our example we want to modify our current Gain factor with the velocity of a played "MIDI" event (noteOn).
- If you need in your plug-in to receive not only audio but events (like MIDI), you have to add an Event input. For this you just have to add in , in order to do this call in the initialize() method of the processor addEventInput:
In this example we add 1 input event bus, receiving only on 1 channel. If you need to receive differentiated events, for example, from different channels, just change it like this:
addEventInput (STR16 ("Event In"), 4); // here 4 channels
2. We create a new internal value mGainReduction (not exported to the host) which is changed by the velocity of a played noteOn, so that the harder you hit the note, the higher is the gain reduction (this is what we want here):
3. Now we have to receive the event changes in the process method:
4. Make use of this mGainReduction in our real processing part:
Add a mono audio Side-chain
In our example we want to modulate our main audio input with a side-chain audio input.
- First add a new side-chain audio input (busType: kAux) in the initialize call of our processor:
2. We want to be sure that our side-chain is handled as mono input. For this we need to overwrite the AudioEffect::setBusArrangements function:
3. Adapt our process using the side-chain input as modulation:
- No labels