vst3_plugin.h

DSP, Plug-in and Host development discussion.
User avatar
KVRist
424 posts since 30 May, 2007

Post Tue Dec 01, 2020 3:43 am

i just uploaded the initial version of vst3_plugin.h, a single-header wrapper/abstraction to make it very easy to create vst3 plugins.. currently linux/gcc only (i think), but there's almost nothing platform specific in it, so it shuld be pretty easy to make it cross-platform.. the header uses just a few c++11 things, but generally it's pretty minimalistic and simple.. it's a quick extraction of the vst3 specific parts from my main library/framework (kode2), so it's probably not optimal yet.. and currently, there's no gui.. .i will work more on it, clean it up, add the few missing things, etc.. also, i will make a more fully working example plugin, and a simple compile script..

MIT license

https://github.com/skei/vst3_plugin.h

here's how you could make a simple plugin like AGain (the "hello world" of plugins?)

Code: Select all

#include "vst3_plugin.h"

class myDescriptor : public VST3_Descriptor {
public:
  myDescriptor() {
    name = "AGain";
    appendParameter( new VST3_Parameter("Gain",1.0f) );
  }
};

class myInstance : public VST3_Instance {
private:
  float MGain = 0.0f;
public:
  void on_parameter(uint32_t AIndex, float AValue, uint32_t AMode) final {
    switch (AIndex) {
      case 0: MGain = AValue; break;
    }
  }
  void on_process(VST3_ProcessContext* AContext) final {
    float*    in0   = AContext->inputs[0];
    float*    in1   = AContext->inputs[1];
    float*    out0  = AContext->outputs[0];
    float*    out1  = AContext->outputs[1];
    uint32_t  len   = AContext->num_samples;
    for (uint32_t i=0; i<len; i++) {
      *out0++ = *in0++ * MGain;
      *out1++ = *in1++ * MGain;
    }
  }
};

VST3_ENTRYPOINT(myDescriptor,myInstance);
no complicated build setup, no makefiles, no external libraries, no mess.. just point gcc to your vst sdk, and compile it.. i don't remember the actual needed gcc arguments, but there's some info about that in the .h file.. it shouldn't be too hard to figure out.. after compilation, put the resulting .so into a directory structure like this: 'AGain.vst3/Contents/x86_64-linux/AGain.so', and you should have a working vst3 plugin.. (tested in linux versions of reaper and bitwig)

KVRAF
6193 posts since 12 Feb, 2006 from Helsinki, Finland

Post Tue Dec 01, 2020 4:52 am

This works without the VST3 SDK?

ps. Oh nevermind, you said "point compiler to VST SDK" so I guess not. Too bad. :(
Preferred pronouns would be "it/it" because according to this country, I'm a piece of human trash.

KVRian
840 posts since 24 Jun, 2002 from UK

Post Tue Dec 01, 2020 5:15 am

impressively minimal!

User avatar
KVRian
875 posts since 2 Jul, 2018

Post Tue Dec 01, 2020 10:15 am

VST3 sdk is indeed heavily over-complicated. This prooves that it is also possible without obfuscation, cmake and a messy project.
Great work :tu:
Tone2 Audiosoftware https://www.tone2.com

User avatar
KVRist

Topic Starter

424 posts since 30 May, 2007

Post Sun Dec 06, 2020 5:50 am

i have dug quite a bit deeper, and i'm working on the next step - getting rid of the steinberg files completely.. so that you don't have to use the official sdk at all.. #include one extra .h file, and off you go.. after all, it's mainly a bunch of typedefs, structs and empty virtual/abstract classes.. i just need to do some utility functions for easier handling of utf16, uuid, strings, etc..

since it 's a derivative of the official sdk, it probably needs to be gpl3..
if i can make it work, of course.. :-)

User avatar
KVRian
717 posts since 26 Oct, 2018

Post Sun Dec 06, 2020 6:37 am

From looking at VST GUI alone I get the feeling to do something else, tho I have the sourcecode for a new delay plugin ready made and it's way awesome, And VST GUI is all I need, "better slider control than the improved editors". It's like pff, all the different places. The simplest thing that could have made any editor's day is to have a discrete step size or standard liniar sliders. Its a big oversight I think.
Last edited by Skupje on Sun Dec 06, 2020 6:45 am, edited 1 time in total.

KVRAF
6193 posts since 12 Feb, 2006 from Helsinki, Finland

Post Sun Dec 06, 2020 6:38 am

If you're using C++11 anyway, then what's wrong with std::codecvt?

edit: In other words, why add UTF16-handling when it already exists in the C++ standard library?
Preferred pronouns would be "it/it" because according to this country, I'm a piece of human trash.

User avatar
KVRist

Topic Starter

424 posts since 30 May, 2007

Post Sun Dec 06, 2020 6:50 am

mystran wrote:
Sun Dec 06, 2020 6:38 am
edit: In other words, why add UTF16-handling when it already exists in the C++ standard library?
that's a good point.. one thing less to struggle with.. :-)
also, uuid's are more or less just a 16-byte array (or 4 uint32's), so most of that part should be pretty easy to clean up and simplify too..

User avatar
KVRian
739 posts since 25 Sep, 2014 from Specific Northwest

Post Sun Dec 06, 2020 8:56 am

tor.helge.skei wrote:
Sun Dec 06, 2020 5:50 am
i have dug quite a bit deeper, and i'm working on the next step - getting rid of the steinberg files completely.. so that you don't have to use the official sdk at all.. #include one extra .h file, and off you go.. after all, it's mainly a bunch of typedefs, structs and empty virtual/abstract classes.. i just need to do some utility functions for easier handling of utf16, uuid, strings, etc..
I'd love to see that! :hyper: :hug:

I did the same with the VST 2 SDK and it's now just one header file of under 1500 lines. It's easier for me to understand and use. I just hate over-engineered, over-coded junk, which is why I've been balking at getting into both VST 3 and AU.

KVRer
5 posts since 8 Aug, 2017 from US

Post Sun Dec 06, 2020 11:11 am

I build from the command line.

I have a .cpp file that does a unity build of the neccessary files (called vst3_unity_build.cpp)

Code: Select all

#define INIT_CLASS_IID
#include "pluginterfaces/vst/ivstmessage.h"

#undef INIT_CLASS_IID
#undef DEF_CLASS_IID
#define DEF_CLASS_IID(x)
#include "pluginterfaces/base/ustring.cpp"
#include "base/source/fdebug.cpp"
#include "public.sdk/source/common/threadchecker_win32.cpp"
#include "public.sdk/source/main/dllmain.cpp "

#include "base/source/baseiids.cpp" 
#include "base/source/updatehandler.cpp" 
#include "public.sdk/source/main/pluginfactory.cpp"
#include "pluginterfaces/base/funknown.cpp" 
#include "base/source/fbuffer.cpp" 
#include "base/source/fdynlib.cpp" 
#include "base/source/fobject.cpp"  
#include "base/source/fstreamer.cpp" 
#include "base/source/fstring.cpp" 
#include "base/source/timer.cpp" 
#include "public.sdk/source/common/memorystream.cpp"
#include "public.sdk/source/common/openurl.cpp"  
#include "public.sdk/source/common/pluginview.cpp" 
#include "public.sdk/source/common/systemclipboard_win32.cpp" 
#include "public.sdk/source/vst/vstaudioeffect.cpp" 
#include "base/thread/source/flock.cpp" 
#include "base/thread/source/fcondition.cpp" 
#include "public.sdk/source/vst/vsteditcontroller.cpp" 
#include "public.sdk/source/vst/vstbus.cpp" 
#include "public.sdk/source/vst/vstparameters.cpp" 
#include "public.sdk/source/common/commoniids.cpp" 
#include "public.sdk/source/vst/vstcomponent.cpp" 
#include "pluginterfaces/base/coreiids.cpp" 
#include "public.sdk/source/vst/vstcomponentbase.cpp" 
#include "pluginterfaces/base/conststringtable.cpp"
#include "public.sdk/source/vst/hosting/pluginterfacesupport.cpp"
And then run something like the following command line call:

Code: Select all

cl /IE:\Repos\3rdparty\vst-sdk_3.7.0_build-116_2020-07-31\VST_SDK\VST3_SDK ../code/vst3_unity_build.cpp ../code/plugin_specific_unity_build_stuff.cpp /link %LINKER_FLAGS% /SUBSYSTEM:WINDOWS /dll /EXPORT:InitDll /EXPORT:ExitDll /EXPORT:GetPluginFactory /OUT:helloworld.vst3
Hope this helps someone.

User avatar
KVRist

Topic Starter

424 posts since 30 May, 2007

Post Sun Dec 06, 2020 1:30 pm

hooray! a little update, before i clean it up and update github.. i got rid of all #includes of the steinberg sdk files, and made a replacement vst3.h file, 1200 lines (36kb).. so, now the plugin is completely stand-alone.. no need for the steinberg vst3 sdk.. the resulting .so is 14.5kb.. reaper (linux) finds it and tries to load it (printf everywhere).. but since i haven't implemented a few necessary utility functions (iid_equal, ascii_to_utf16, utf16_to_ascii), it fails.. but at least now i know it can be done..

edit: updated github

KVRAF
6193 posts since 12 Feb, 2006 from Helsinki, Finland

Post Sun Dec 06, 2020 2:52 pm

syntonica wrote:
Sun Dec 06, 2020 8:56 am
I did the same with the VST 2 SDK and it's now just one header file of under 1500 lines.
I just gave up with headers completely when it comes to VST2. My current wrapper that does most of what I need is one .cpp file under 500 lines. :)
Preferred pronouns would be "it/it" because according to this country, I'm a piece of human trash.

User avatar
KVRian
739 posts since 25 Sep, 2014 from Specific Northwest

Post Sun Dec 06, 2020 3:08 pm

mystran wrote:
Sun Dec 06, 2020 2:52 pm
syntonica wrote:
Sun Dec 06, 2020 8:56 am
I did the same with the VST 2 SDK and it's now just one header file of under 1500 lines.
I just gave up with headers completely when it comes to VST2. My current wrapper that does most of what I need is one .cpp file under 500 lines. :)
There's just so much going on in there that's plain wrong. But I'm down to what it should have been. I'm sure if I deleted all the deprecated stuff, along with the speaker placement stuff, I'd hit about 500 lines, too. :D

I've been poring over the VST 3 headers there and now I'm actually understanding what's going on. It's like VST 2, only more needlessly complex. :hihi:

I already see stuff that's trying to be "helpful" which will have to be edited out. I also need to look at UUIDs and why we need them. I guess 4-char IDs just aren't enough anymore. :P

EDIT: I just checked and my VST2 header is actually at 950 lines. It's the awkward location of the VSTPliginMain that bothers me. I have it tucked down at the bottom of my main class. But having done all of this, my codebase feels so light and airy now!

User avatar
KVRist

Topic Starter

424 posts since 30 May, 2007

Post Mon Dec 14, 2020 6:35 am

did some more cleaning up.. it's also now part of the next/updated version of my plugin library/framework (kode2).. but since there's still some time before i will publish that, i (temporarily) added the kode_vst3_base.h file to this repository, so you can have a look if you want.. it probably still needs some tweaks and more cleanups (tabs vs spaces and stuff like that)..

https://github.com/skei/vst3_plugin.h/b ... st3_base.h

Return to “DSP and Plug-in Development”