You are viewing an old version of this page. View the current version.
This tutorial will explain you 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 a audio signal and can be loaded into VST3 hosts like Cubase, Wavelab,...
Part 1: Get and install the VST 3 SDK
For downloading the SDK see this section "How to setup my system in order to build VST3 plug-ins".
You have the different 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 and then adapt each file where comment mentions it.
- or, which is easier and recommended, you can use the VST3 Project Generator application included in the VST SDK.
Part 2: Use 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 wanted information: see Setting the Preferences
In the Create Plug-in Project tab you have to enter some information about your Plug-in you want create:
Then when all field have been filled, you could click on Create, a script is started which creates in the Output Directory a project with adapted files, after this step the IDE (Visual Studio or XCode) is launched.
You can then compile the project and test your newly created Plug-in.
If you have choose 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. In the following sections, it will be explained how to add a new parameter, its associated processing algorithm, and others specific features like saving/loading project or presets, create a dedicated User Interface,...
A VST 3 Plug-in contains two main classes: its PlugProcessor (the main part doing 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 should modify the volume of the audio going thru 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, here we choose to assign the unique number 102.
2. Open now the plugcontroller.cpp file, and add the gain parameter with the parameters.addParameter
- we add the flag kCanAutomate which will inform the DAW/Host that this parameter could be automated if wanted. (what is automation?)
- 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 we will adapt the processor part for this new parameter. Open the file plugprocessor.h and add gain value Vst::ParamValue mGain. This value will be used for the processing to apply the gain.
Add the process applying the gain
- we need to set our internal mGain with its wanted value from the host, this is the first step of the process method, parse the parameters change coming from the host in the structure data.inputParameterChanges for the current audio block to process.
2. Now the real processing part:
3. VST 3 includes a way for the host to inform the Plug-in that its inputs are silent or not (using the VST 3 silence flags), we will show how to take care of this:
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 plugprocessor.cpp add in the getState method the mGain value to the state stream given by the host which will save it as project or preset.
2. In the setState () method the Plug-in get from the host a new state (called after a project or preset is loaded).
Part 4: Next Advanced Steps
Add a Event Input
In our example we want to get modify our current Gain factor by a the velocity of a played "MIDI" event (noteOn).
- If you need in your Plug-in to receive not only audio but event (like MIDI), you have to add a 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 for example to receive differentiated events 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 will be changed by the velocity of a played noteOn, harder the note is played higher will be the gain reduction (this is what we want here):
3. now we have to get the event changes in the process method
4. make use of this mGainReduction in our real processing part:
Add a Audio Side-chain Mono
how to add a Audio Bus + add use of SC in the processing
- No labels