VST 3 from scratch – Part 1

Steinberg’s Virtual Studio Technology aka VST is a quite powerful tool for audio programming which allows to decouple all the audio resources management (loading, streaming or decoding) from the actual processing. Everything is handled by the host application so the VST developer can focus on the effect / instrument itself. Unfortunately this comes with the overhead of a not very intuitive API whose documentation is not the best.

In this post we will show how to create a working VST 3 project from scratch. So, first thing will be download the required tools and sources:

PROJECT CREATION AND SETUP

To create the Visual Studio Project select File -> New -> Project and select the Visual C++ -> Empty Project template. Type the project name (ie: Vst3) adjust the location and press OK.

FILTERS AND EXTERNAL SORUCE

Remove the filters created by default (Header Files, Resource Files and Source Files).

Create a folder named resources in your project location and, back to Visual Studio, add a filter ( right click on Vst3 project in the solution explorer -> Add -> New Filter) , give it the same name as the new folder. We will come back to this filter later.

Create a folder named external in your project location and unzip there the contents of the VST 3 SDK. Inside it replace the vstgui4 folder by the up to date version from github. Add a filter to the Vst3 project and name it external. In order to add the required sources from VST3 SDK, create another filter under external and name it vst3sdk. Sources to add (right click under vst3sdk -> Add -> Existing Item) are (paths are relative to VST3 SDK folder):

base/source/baseiids.cpp 
base/source/classfactory.cpp
base/source/fatomic.cpp
base/source/fbuffer.cpp
base/source/fdebug.cpp 
base/source/fobject.cpp 
base/source/fstreamer.cpp 
base/source/fstring.cpp 
base/source/fthread.cpp 
base/source/timer.cpp 
base/source/updatehandler.cpp 
pluginterfaces/base/conststringtable.cpp 
pluginterfaces/base/funknown.cpp 
pluginterfaces/base/ustring.cpp 
public.sdk/source/common/pluginview.cpp 
public.sdk/source/main/dllmain.cpp 
public.sdk/source/main/pluginfactoryvst3.cpp 
public.sdk/source/vst3stdsdk.cpp 
public.sdk/source/vst/vstguieditor.cpp 
public.sdk/source/vst/vstinitiids.cpp

Last filter to add would be for VSTGUI sources, add it under external and name it vstgui. Under that filter add:

vstgui4/vstgui/vstgui_win32.cpp

At this point our Visual Studio Vst3 project hierarchy should look like the graph below:

wpg_div_wp_graphviz_1

NOTE: All the naming and filters configuration can be customized as your discretion.However this post (and the github sources) will follow that hierarchy.

PROJECT PROPERTIES

Access the Visual Studio project property pages (right click Vst3 project -> Properties ) and change the properties listed below. Make sure to select All Configurations and All Platforms in the top unless specified.

    • General
      • Target Extension: .vst3
      • Configuration Type: Dynamic Library (.dll)
    • VC ++ Directories
      • Include Directories: Add the relative paths to Vst3 Sdk and VSTGUI source folders. This might change depending on how you structured your source folders, in our github they are ..\..\..\source\external\VST3 SDK\vstgui4 and ..\..\..\source\external\VST3 SDK.
    • C/C++
      • Preprocessor Set Preprocessor Definitions, in this case we want to set different values for different Configuration / Platform values as described below.
        • Debug Win32 / x64: WIN32;_WINDOWS;DEVELOPMENT=1;%(PreprocessorDefinitions)
        • Release Win32 / x64: WIN32;_WINDOWS;RELEASE=1;%(PreprocessorDefinitions)
      • Precompiled Headers. Set to Not Using Precompiled Headers
    • Linker -> Input In order to declare to declare the Module Definition File, create Vst3.def file in the same folder as the Visual Studio solution with the contents shown below and set value of the property accordingly.
      EXPORTS
       GetPluginFactory

VST3 REQUIRED CLASSES

VST3 SDK introduced a nice philosophy in order to decouple the audio processing from the UI and parameters related logic, in a similar fashion as the Model View Controller design pattern. In this section we will briefly describe each of the required classes to achieve that.

Editor

The Editor class represents the UI side of the audio plugin, purely dedicated to look and feel, layout and arrangement of the widgets and views which compounds your plugin. You do not want to add business or audio logic here. Your plugin should be able to work with 0 to many instances of its Editor (that means NONE or multiple instances).

Using the VSTGUI SDK the Editor class has to inherit from Steinberg::Vst::VSTGUIEditor.

Controller

This will be the bridge between the plugin Editor windows and the Processor, handling all communication between them and all parameter changes. There will be only one instance of the controller.

Controller class has to inherit from Steinberg::Vst::EditController.

Processor

And finally here it comes the audio processing part 🙂 This class should purely take care of the digital signal processing related code. There will be only one instance of the processor.

Processor class has to inherit from Steinberg::Vst::AudioEffect.

 

That’s all for now. Source code is available on github. In future posts we will learn how to build a VST2 wrapper or how to add parameters in order to implement a real working audio effect.

Posted in VST.

Leave a Reply

Your email address will not be published. Required fields are marked *