Vst Plugin Gui Designer

Posted By admin On 21.12.20

It’s time to create a better user interface for our digital distortion plugin. Here’s the look we’re going for:

Download vstgui for free. Cross platform C library for developping audio plugin´s UI. VSTGUI is a cross platform C library mainly for developing user interfaces for audio plug-ins (VST, AudioUnit, AAX, RTAS, etc). JVST provides an interface to VST plugins (effects and instruments) for use in Java. It allows the developer to interact with a plugin, process samples and use any built in GUIs. JVST is licensed under the Common Public License (CPL). Integrated GUI Designer ASPiK plugins all include a full-featured drag-and-drop GUI designer that can be used in.any. AAX, AU or VST host for MacOS or Windows. Here is the GUI Designer running inside of an AU. GUI design for synthesizers, VST plugins, DAWs, iOS and Android audio apps by Voger Design.

It’s not awesome, and just to demonstrate how we can add graphics and – more interestingly – how to create the rotating knob.

Lower audio vst free. Here‘s the TIFF of the design. Open it in Photoshop (or your preferred tool) and have a look at the different layers and groups. As you can see, the only part that’s really going to change is the knob. So we can export the rest as one PNG:

Adding the Background for Mac Builds

Click on the above image and save it to your desktop. Open the DigitalDistortion project in Xcode. In the project navigator, expand the Resources folder and drag your image into the img folder inside of that:

Make sure you check the Copy items into folder option and add it to all targets:

Adding the Background for Windows Builds

For Visual Studio, adding a resource (like an image) to your project is a little different. Adding to all targets on Mac means that the image will be included into the .app, .vst and .component files you ship to your users.
To achieve this with Visual Studio, edit your project’s .rc file. For this project it’s called DigitalDistortion.rc. When you open it, the top looks like this:

First, resource.h is included, so all the #defines from there are available here. The line below that declares that the knob should be included. So to include the background as well, add this line just below that:

We’ll add BACKGROUND_ID and BACKGROUND_FN to resource.h in a second.
Whenever we add an image to our project, we have to to add a line like this.

Using the Background

Let’s reference the image from our code. Go into resource.h and change the GUI size (around line 62):

…and add the background image ID and filename:

In DigitalDistortion.cpp, change the constructor code to attach background.png instead of the red color:

That was easy! Run the APP target and you’ll see the nice background:

If the background isn’t working on windows, you may have to put background.png inside the folder DigitalDistortionresourcesimg, so it’s found correctly.

Adding the knob

The knob is slightly more difficult. Have a look at the design again and you may see how the knob consists of a textured part and some reflections. When you turn a knob, the metal itself moves, but the lamp on your ceiling sure doesn’t! So some parts of the graphic should rotate (metal texture, the black arrow), while others should stay fixed (anything due to light). What about the “outer ring”? It has some contour, but all of that is due to incidence of light, so it shouldn’t rotate.
That’s why we can’t just export the knob in twelve-o’clock-position and rotate it at runtime.
To be more precise, there should be a knob base which doesn’t rotate. On top of that, we need the metal texture which does rotate. And finally we need another layer with the light reflections which doesn’t rotate. These are the three parts, exported separately (the black background is just added so you can see everything):

There’s a very good tool for this. It’s called KnobMan, it’s freeware and it’s made for this exact purpose. Download JKnobMan for your system, start it and load the knob file I’ve prepared:

All I’ve done is add the three layers and change some coordinates so the metal texture rotates correctly without moving around. There’s a tutorial available if you want to get deeper into the software.
Export (Cmd+E, Ctrl+E on Windows) the knob to a file and name it knob.png (or download mine). The PNG has 128 frames covering all rotations, and only the metal & arrow are rotated. Nice!

Back in Xcode, right-click the existing knob.png and click Delete. In the following prompt, select Move to Trash. Now drag the knob.png onto the img folder and do everything the same way as for the background image above.
Since the filename is the same, we can leave resource.h alone. Go straight into DigitalDistortion.cpp and change the enum ELayout as follows:

We don’t even have to tell WDL that the knob is bigger than the previous one! We just say “the PNG has 128 frames in it” and specify where the knob should be placed.
Run your plugin as VST2 and check out how you can turn the knob and it will go through the rotation frames. What’s confusing, though, is that our plugin does distortion and having the knob at 100% gets us a clean sound!

Correcting the Knob Direction

Let’s change that in line 98:

To prevent the division by zero problem described earlier, we also have to modify line 33 so that the parameter defaults to 0 and will not exceed 99.99:

If you run again, the plugin should work as expected. It might be a good idea to rename the variables from Threshold to something like DistortionAmount. The only thing still representing a threshold is the internal mThreshold variable.

Summary

With minimal DSP code we have created a working distortion plugin with a custom user interface. This was to give you an idea of what goes into creating an audio plugin – sort of the big picture.
Now that we have an overview, we’re ready to get into more interesting signal processing: The next post will be about synthesizing waveforms.

If you got stuck somewhere, you can download a ZIP with all files here.

Further Reading

  • There are a lot of free KnobMan examples here and here.

Credits

  • The metal look is based on this Photoshop tutorial. Thanks to the author!
  • Thanks to g200kg for KnobMan!

Introduction

Microsoft announced that it would offer Visual Studio Express free of charge forever. Though the Express version of Visual C++ (hereafter referred to as VC++) has some limitations, it’s still a great tool and it’s nice to see Microsoft taking some steps to support the developers writing software for their platform. This document will describe how to get VC++ installed and building VST plugins. It assumes that you have prior experience developing VST plugins, and are familiar with the structure and layout of the VST SDK.

If you are trying to write VST’s in a language other than C++, than this guide is not for you. There are lots of other frameworks out there for developing VST plugins in other languages (such as C#, Java, Ruby and Python, just to name a few).

This tutorial will walk you through the process of installing and configuring the tools you’ll need to build your own VST plugins with Visual Studio, and creating a simple VST plugin with optional support for a VSTGUI frontend. This guide only covers building VST 2.x plugins, as the VST3 SDK is not very widely supported yet. Note that Steinberg’s website is a bit confusing and it is easy to accidentally download the wrong version of the SDK, so double-check to make sure that you have the 2.4 SDK.

Download required packages

  1. Steinberg’s VST SDK, which requires you to make a free Steinberg Developer account.
  2. Microsoft’s Visual C++. This guide uses the 2010 Express edition, as it was the latest version at time of writing.
  3. Libpng and zlib (optional)

Install Visual C++

If you already have a working installation of VC++, you can skip this step. Otherwise, download VC++ and install it. The standard installation should be OK, but you can choose to perform a custom installation if you don’t want documentation or other stuff installed with it. Before installing VC++, you must remove any other versions of VC++ on your computer.

Next, download and install the Platform SDK, which will provide you with the standard header files and libraries you’ll need to build software. You may choose to install VC++ anywhere on your hard drive, but the default location is C:Program FilesMicrosoft Visual Studio 10.0.

Creating your project

Create a new project of type “Class Library”, which we’ll call YourProjectName. In the rest of this tutorial, whenever you see YourProjectName, replace that text with the actual name of your project.

In Visual Studio 9, you’d make a new project with the wizard found at File -> New -> Project. Select Visual C++ -> Win32 Console Application, and choose a directory for your project. When the wizard opens, press “Next” and select DLL as the Application Type. Also check the “Empty Project” box.

If you prefer not to start with an empty project, then you can remove all of the files that VC++ creates for you, but keep the resource.h and YourProjectName.rc files, and remove any references to these files (such as YourProjectName.ico being listed in the resource file).

Add Source Code to the Project

If you already have source code for your plugin, simply add it to the project. Otherwise, you need to create the following files:

  • YourProjectName.cpp
  • YourProjectName.h
  • resource.h (Only needed if building a plugin GUI)
  • YourProjectName.rc (Only needed if building a plugin GUI)

You will also need to add the files from the VST SDK, which includes everything under the vstsdk2.4/public.sdk/source/vst2.x and vstsdk2.4/pluginterfaces/vst2.x directories. I usually prefer to manually make groups for these directories and drag the files to the groups from Explorer, as dragging the entire “vstsdk2.4” directory to VS can cause it to choke when it tries to add a bunch of unused files to the project.

To start out with, the plugin’s entry point header file (YourProjectName.h) should look something like this:

The accompanying class definition (YourProjectName.cpp) should look something like this:

Note that your project won’t compile just yet, but be patient!

The above code samples are simply blank entry points which don’t do anything exciting. The VST SDK offers lots of methods which you can override in order to do things like setting parameters, receiving MIDI messages, and so on. These things are beyond the scope of this tutorial; if you don’t know what code to put inside of processReplacing, try checking out the “again” example distributed within the VST SDK in the public.sdk/samples/vst2.x/again folder.

You must also create a module definition file for your project, named YourProjectName.def. Usually this file is placed in the same directory as the VC++ project file, but you may place it somewhere else so long as this definition matches the Module Definition File settings in the Linker section of the project preferences. This is just a plain-text file which should contain the following text:

Configure build settings

Go to the project settings either by right clicking on the project in the solution explorer and then selecting “Properties”. Make the following changes to the project for all build configurations:

  • General
    • Character Set: Not Set
    • Common Language Runtime Support: No Common Language Runtime Support
  • C/C++
    • General:
      • Additional Include Directories:
        1. (or wherever you put the VST SDK)
        2. Your source code directory
        3. Any other directories which you may have header files stored in Global SDK directories, such as
    • Preprocessor:
      • Preprocessor Definitions:
      • For Debug builds you may also wish to add
      • If you wish to use PNG graphics for a VSTGUI frontend, add
      • To avoid lots of compiler nags and warnings, define
      • In some cases, you may also need to define
    • Code Generation:
      • Runtime Library: Multi-threaded. Multi-threaded debug may be used for debug builds. This will build the VC++ common runtime library statically into your plugin, increasing its size by approximately 200Kb. If you choose to use the CRL as a dynamic library, then you must also distribute a copy of the CRL with your application, which complicates deployment and distribution.
    • Precompiled Headers:
      • Precompiled Header: Not Using Precompiled Headers. Yeah, this makes rebuilding a bit slower, but will avoid a bunch of weird errors as you are getting your project set up. Once you get the project building you can revisit this step.
  • Linker
    • General:
      • Additional Library Directories: Add any other library directories which your project depends on.
    • Input:
      • Additional Dependencies (for Release builds):
        • libcmt.lib
        • uuid.lib
        • shell32.lib
        • ole32.lib
        • gdi32.lib
        • User32.lib
        • advapi32.lib
        • zlib.lib (only if you are building with a GUI)
        • libpng.lib (only if you are building with a GUI)
      • Additional Dependencies (for Debug builds):
        • shell32.lib
        • msvcrtd.lib
        • ole32.lib
        • gdi32.lib
        • User32.lib
        • advapi32.lib
        • zlib.lib (only if you are building with a GUI)
        • libpng.lib (only if you are building with a GUI)
      • Ignore Specific Default Library (for Release builds):
        • msvcrt.lib
        • libc.lib
        • msvcrtd.lib
        • libcd.lib
        • libcmtd.lib
      • Ignore Specific Default Library (for Debug builds):
        • libcmt.lib
        • libcmtd.lib
        • msvcrt.lib
      • Module Definition File: YourProjectName.def

Adding support for VSTGUI (optional)

Include VSTGUI support in your plugin, simply add the VSTGUI files into your project in addition to your own editor class. At a very minimum, these are:

  • aeffguieditor.cpp
  • vstcontrols.cpp
  • vstgui.cpp

Adding support for PNG graphics (optional)

If you would like to use PNG’s in your plugin instead of BMP graphics, you will need to also build your own version of libpng and zlib. Download the source code for both libraries from the links given in the “Requirements” section of the document and place them in the same directory. There is a Visual Studio project for libpng which will also build zlib for you; it is located in the projectsvisualc71 directory. In order to get the projects to build correctly, you’ll need to rename the source code directories to simply “libpng” and “zlib”, removing the version numbers from the directory name.

When you open the project up, VC++ will run you through the project conversion wizard. Convert the project, and change the “Runtime Library” settings in both libpng and zlib to be Multi-Threaded, as described above. Unless this step is performed, the dependency on the CLR will be present in your project. Next, choose the LIB ASM Release or LIB Release build style and build the project; if you build the libraries as DLL’s, you will be unable to statically link them into your plugin. The project should build ok, but throw a few errors when attempting to run the pngtest files. You can ignore these problems, as the libraries will still be correctly compiled and can now be linked to your project.

Visual Studio doesn’t need to have the libraries within your actual project. Instead, place the libraries in a directory of your choosing and be sure to add this path to the list of “Additional Library Directories” in the Linker preferences for your project. You may choose to place the libraries in the same directory as the Microsoft Platform SDK stuff, but I personally prefer to keep them in a separate directory checked into version control. Also be sure to add references to libpng.lib and zlib.lib for your project in the “Additional Dependencies” section of your Linker preferences for the project.

The path must be relative to the location of the project file. Then, in resource.h, add the following preprocessor definitions:

Now you can use IDB_BITMAP1 (or any other name of your choosing) in your code when creating new CBitmap objects.

I have heard some reports of vstgui.cpp not compiling properly due to the missing symbol png_set_expand_gray_1_2_4_to_8. Changing png_set_gray_1_2_4_to_8 to png_set_expand_gray_1_2_4_to_8 in vstgui.cpp seems to fix this issue.

Final considerations

VC++ ships with an optimizing compiler, but sometimes the compiler will choke on certain files and optimization must be disabled. In particular, I have experienced this with Laurent de Soras’ FFTReal libraries, since they are written as template classes. In general, however, optimization is a good idea, as is “Eliminating Unreferenced Data” (in the linker settings). The “Whole Program Optimization” setting appears tempting, but usually results in dozens of build errors and problems, so it’s best to avoid this. Also, be sure to use the optimization features of this compiler and linker, as they can greatly boost runtime performance.

If you are developing on a multi-core machine, then you might need to disable parallel builds by setting the number of parallel builds to 1 under Tools -> Options -> Projects and Solutions -> Build and Run. In past verisons of VS, I noticed that the compiler does not always link projects in the order one would expect, which caused odd errors during linking about missing symbols. However, VS2010 users probably shouldn’t need worry about this setting.

Unresolved symbols when linking

Sometimes you may see errors like the following:

If you are getting errors in your build about missing symbols, make sure that you double- and triple-check the debug and release configurations for the library configuration above, since some of the libraries which are used in one build style are specifically excluded from the other. Also, when you close and re-open the project’s build properties, VS always “forgets” the last selected build style, so remember to check and set this appropriately.

Also, you should check to make sure that the Platform SDK was correctly installed on your system and that your project’s include and library paths are pointing to these directories.

Unresolved external symbols

If you are seeing errors like this:

Then this most likely means that the file which contains the given symbol is not correctly added to the VC++ solution.

Linking errors with symbols defined multiple times

Vst Plugin Gui Designer App

This is undoubtedly one of the most frustrating problems which can occur when building a VST in VC++. If you are seeing error messages like this, then it most likely means there is some problem with your library configuration:

Microsoft’s Platform SDK

Most likely, the libcmt and msvcrt libraries are being included incorrectly in your build. Double-check the library list above, keeping in mind that the recommended configuration uses libcmt for release builds only, and msvcrtd for debug builds only.