Skip to content

02_Getting_started_windows

Oli Larkin edited this page Aug 18, 2024 · 15 revisions

Requirements

You should have at least a basic knowledge of C++, familiarity with git version control and be reasonably comfortable using the command line/terminal.

You need to have the followings tools installed:

Other useful tools are:

  • Windows Terminal2 - An excellent modern terminal
  • Visual Studio Code - A text editor that can be useful in addition to Visual Studio Community
  • Reaper - You will need a DAW in which to test plug-ins that you build

Set up your development environment

It's good to keep your coding projects organised. In order to facilitate building complex projects for multiple platforms, iPlug2 has a well defined folder and project structure, which you are strongly advised to stick to. Advanced users may try to build iPlug2 with their build-system of choice (See also Out of Source Builds).

Personally I like to keep my programming projects in a sub-folder of my Windows user folder called Dev. e.g.

C:\Users\oli\Dev\iPlug2

The exact path is not important, but I'd advise a short path if possible without any spaces in the folder names. In order to set up iPlug2 in this location, first create the Dev folder in Explorer. On Windows there are multiple types of terminal/shell that can be used (Command Prompt, PowerShell and Git-Bash). Since git originates from the Linux world, it's often better to use it with the Git-Bash shell which uses unix commands and syntax. In iPlug2 bash shell scripts are used since they can work on macOS and Windows via Git-Bash. To create a Git-Bash terminal right click in the Dev folder in Explorer and Select Git Bash here (you need to have enabled shell-integration when you installed Git For Windows).

You can now clone the iPlug2 repo using git. You can also download a .zip file from here, but it's recommended that you clone using git in order to easily stay up to date with upstream changes.

oli@BEAST MSYS ~/Dev
$ git clone https://github.com/iPlug2/iPlug2.git

After it has checked-out the repository you will have the iPlug2 folder with the source code inside. We could jump in now and build an example, but if we want to build e.g. a VST3 plug-in we need to download the VST3 SDK and put it in the correct place for the iPlug2 projects to find it. iPlug2 includes some scripts to help with downloading of dependencies. NOTE: The AAX SDK and the VST2 SDK are not in the public domain, so if you want to build those formats you need to have access to those SDKs and place them in the iPlug2/Dependencies/IPlug folders manually.

oli@BEAST MSYS ~/Dev
$ cd iPlug2/Dependencies/IPlug
$ ./download-iplug-sdks.sh

The last line executes the script to download the VST3 SDK and put it in the correct place. Whilst we are here, we can also download some pre-built static libraries using another script, that may be useful at a later stage (for example if you want to try and use a different graphics-backend than the default).

oli@BEAST MSYS ~/Dev
$ cd iPlug2/Dependencies/
$ ./download-prebuilt-libs.sh

Note that the dependencies folders include README.md files which explain the contents of the folder.

Compile an example project

The Examples folder contains many projects that you should now be able to compile. Let's open and compile the IPlugInstrument example.

oli@BEAST MSYS ~/Dev
$ cd iPlug2/Examples/IPlugInstrument
$ start IPlugInstrument.sln

This will open the Visual Studio Solution, which encapsulates four "Projects" for the different plug-in formats that are supported on Windows. To start, let's build the IPlugInstrument-app project, which is a standalone application with audio and MIDI I/O. Right-click IPlugInstrument-app in the "Solution Explorer" and select "Set as Startup Project" - it should turn bold. This means that when you click the build/debug button, this project will be built. Now select "x64" from the "Solution Platforms" menu (instead of Win32) in order to build for the x64 architecture. Now click the green play button or press F5 to build and debug the app. Hopefully it builds smoothly and you see the interface on the screen. You may need to change the Audio/MIDI settings in the preferences dialog in order to be able to play/hear anything.

Now you have built the app, try building a VST3 plug-in. Right-click IPlugInstrument-vst3 in the "Solution Explorer" and select "Set as Startup Project" - it should turn bold. Now you can build the VST3, and it should launch Reaper, but first, you may need to give yourself write permissions for your VST3 plug-ins folder - otherwise the build will fail when it tries to copy the new plug-in into place.

Navigate to C:\Program Files\Common Files\VST3 in explorer and right click, selecting "Properties". On the "Security" tab, give the group "Users" full control. Hopefully now you can build the VST3 project and it will launch Reaper, loading a project including the plug-in.

OPTIONAL: If you want to debug with a host other than Reaper, you need update the file iPlug2\common-win.props which contains global configuration data that is shared by all the Visual Studio projects. There is a script to help you modify this file in order to select some from some common DAWs. You can choose different options for 32 bit and 64 bit debugging, and for VST2 and VST3 plug-ins. If the predefined paths in the script don't match the locations where you installed the .exe that you want to use for debugging, you can also just manually edit common-win.props, either in Visual Studio or in a text editor.

oli@BEAST MSYS ~/Dev
$ cd iPlug2/Scripts
$ python select_host.py

Before we move on to making our own project, let's tweak the IPlugInstrument code slightly to prove we are building the plugin. Expand the IPlugInstrument-vst3 project in the solution explorer, and double click IPlugInstrument.cpp to view it in the code editor. Find the plug-in constructor, which is the block of code towards the top of the file starting with IPlugInstrument::IPlugInstrument(const InstanceInfo& info){ /* ... */ }. The plug-in constructor is where your IPlug plug-in C++ class gets created. Lots of initialisation happens here, including setting up parameters, presets and laying out the user interface. Let's change the background color from gray to white.

Find the following line of code (around line 27):

pGraphics->AttachPanelBackground(COLOR_GRAY);

and change COLOR_GRAY to COLOR_WHITE

Now rebuild the project and you should see that the background has changed to white.

Start your own, new project

All the iPlug2 example projects can be used as templates for new projects. A python script "duplicate.py" is used to clone a project folder doing a multi-file find and replace to change all occurrences of the template name with the new name.

In this case, we will create project called MyNewPlugin based on the IPlugEffect project, which is the simplest iPlug2 example - just a volume control. The following commands can be used to do that. You can replace MyManufacturerName with your company name, which should not include spaces.

oli@BEAST MSYS ~/Dev
$ cd iPlug2/Examples
python duplicate.py IPlugEffect MyNewPlugin MyManufacturerName

Now we have a new folder MyNewPlugin, with Visual Studio projects (and Xcode projects for mac) already set up so we can compile straight away. Before we do that though, let's initialise a git repository for our new project, add all the files and make an initial commit.

oli@BEAST MSYS ~/Dev
$ cd iPlug2/Examples/MyNewPlugin 
git init .
git add *
git commit -m "initial commit"

Now everything is under version control, any changes can be reverted, which is a very useful thing! We could now go and create a repository at github (or similar) for our project, and add it as a remote, so we can store and manage the project "in the cloud". This is convenient if we need to check out the repo and build it elsewhere.

You should now open your new project...

oli@BEAST MSYS ~/Dev
$ cd iPlug2/Examples/MyNewPlugin
$ start MyNewPlugin.sln

It's important that the project has the same relationship to the rest of the iPlug2 source code, but it doesn't have to be in the Examples folder. Typically for my own projects I make a folder parallel to Examples called Projects.

You now know the basics of setting up iPlug2 on Windows :-)

Clone this wiki locally