1: The Toolchain

NOTE THIS TUTORIAL SET SHOWS YOU THE HARDER WAY TO TO THINGS. CHECK OUT THE SECTION ON BUILDING FROM WITHIN AN IDE FOR THE EASY WAY. SOME MAY STILL FIND IT USEFUL TO SKIM OVER THESE TUTORIALS. In this first tutorial I will explain the tools which you need to download in order to build and test your VST plugins and I will explain step-by-step how to configure everything so even a complete novice (like myself) will be able to get up and running. The essential free tools you need for this tutorial are in the following list, but don’t download anything just yet . . . .

  1. Mingw C++ compiler http://www.mingw.org/
  2. Python scripting language http://www.python.org/ (this is just for SCons and not for plugin development)
  3. SCons build tool http://www.scons.org/
  4. The VST sdk version 2.4 http://www.steinberg.net/

The following is a list of free stuff which will make your life easier:

  1. A VST Host in which to run your plugins. I guess you already use a VST hot of some kind if you are reading this tutorial, but if not then I recommend Hermann Seib’s free VST host http://www.hermannseib.com/english/vsthost.htm
  2. A decent text edidor. Windows Notepad will do the job but you’ll be much better off with a fully featured editor. I really like Crimson http://www.crimsoneditor.com/
  3. Finally I recomend a decent console as windows cmd is just plain painful to use and difficult to paste in commands. I like the console sourceforge project http://sourceforge.net/projects/console/ (get the latest development version as they are much nicer than the 1.0 stable release)

Ok, firstly we need to get the compiler up and running so go to the MinGW page and head over to the download section. You want to use the automated installer (this is a newbie guide afterall). Download the exe version and run it. You’ll be asked which compilers you want to install, and we only need the c++ stuff (gcc) and not the FORTRAN compilers etc.  Save the mingw to your c drive, so something like c:\MinGW. The mingw downloader can be a little temperamental sometimes, so if a file fails to download keep retrying until you have all the files.

The next step is to add the binaries to your path and then check that windows knows where to find your c++ compiler. To do this click on the start menu, then right click on “my computer” and select “properties” from the list. Go to the “advanced” tab and then select the “environment variables button”. You will the be faced with something which looks like the following:

path1

Now in the lower box which is titled “System variables” double click on the Path value. If it doesn’t exist then create it. Move to the end of this string and then add a semicolon and then WITHOUT A SPACE CHARACTER, paste or type the folder in which the c++ compiler resides. If you installed to c:\MinGW, then this will be “c:\mingw\bin”. Ok and apply all changes and now we check if everything works. Open up a command window (start/run/cmd) or the console application if you downloaded it like I suggested, and type “gcc -v” at the prompt without the quotation marks, from any directory. If all has gone well then you will see some info about your compiler.

cons

That is the first hurdle out of the way. Now, most users of the GNU compiler collection may be familiar with a very un-good build tool known as make (excuse the stong opinion, it is just that I was evangelised by a SCons user early on), where as here I will show you how to use a much nicer and more flexible tool known as SCons, which is short for software construction tool. A build, or construction tool runs from a script, which will handle all of the dependencies of your project and special compiler flags etc. Scons will check the md5 check-sum of each of the source files in your project, and if any have changed since the last build, they will be rebuilt. This saves you compile time and a lot of work typing into the command prompt. In the next tutorial you will see how much easier scons syntax is than makefile syntax, but for now we just need to get it up and running.

Go to the python site, download and install the latest release of version 2.5 **DON’T BE TEMPTED TO GET A NEWER VERSION** as this may not be compatible with SCons, however, this is likely to change from the time this tutorial was written (be sure to check SCons site). Once you have done this you must download install SCons from the link at the top of this page. SCons will detect the version of python which you just installed and will attach itself to the python install. To let windows know trhat scons exists, you must add it to your path using the same procedure outlined for adding mingw to your path, however this time you must add “c:\python25\scripts;” after the last semicolon with no spaces if you have installed python to c:\python25. To see if this has worked, you need to open your console window once again and type “scons -v”.

cons2

To install the final part of this jigsaw puzzle, head over to the Steinberg site and go to the company / third party developers section and download the 2.4 version of the sdk (you will need to register with the site first) and extract it to c:\vstsdk2.4. Most developers on the web and forums are using version 2.4 of the sdk as few vst hosts support the vst 3.0 standard and there is apparently little to gain from trying to develop under 3.0. You now have all the tools required to build your first plugins. See the next tutorial.

vstlogoalphasm1

  1. Valentin
    October 14, 2009 at 12:22

    Hey.. just a short hint for “copy paste users”… The path variable for Python shall be “c:\python25\scripts;” instead of “c:\python25\scrips;” (that is : WITH A “T” in word scripTs…) that’s actually just a typo, but took me a while to find out what wasn’t working… You may wanna correct that one…

    Otherwise, thanks very much for the tutorial : helped me a lot

  2. October 14, 2009 at 13:18

    Excellent observation Valentin. Many thanks. I updated this immediately on seeing the error and I’m glad you found the site useful.

  3. TinkRGnome
    November 11, 2009 at 05:25

    dear bmoviehorror,

    i like that you have a tutorial on VST building, though i had a question about VST building
    with codeblocks. i have almost no C/C++ knowledge, i seriously want to learn/understand how to build programs/VST synth & effects plugins with codeblocks. i read earlier in here that it would be definitely possible. i just recently installed code::blocks 8.02 that has the GCC compiler included. could i possibly just use that & the VST SDK to make plugins with? i do beleive i am a fairly quick learner at some things, afterall i found that i learned classic vb6 fairly quickly, i seemed to have learned how to build some decent synths with max/msp, and i’m hoping codeblocks wont be a terrible level complexity in understanding how to use it.

  4. TinkRGnome
    November 13, 2009 at 07:51

    yeh …

    that link you gave me is a page i was on asking about the same thing earlier this week actually
    thanx for the help tho. 😐

    • November 13, 2009 at 12:25

      I’ll have to write something on that soon. As you said, code::blocks is built around the gcc compiler – which is what I use in these tutorials via the SCons build tool, so it should be really simple to convert. I’ll try make a sketchy blog post soon which replicates the build tutorials for code::blocks.

  5. TinkRGnome
    November 14, 2009 at 03:54

    i have both VST sdk 2.3 & 2.4
    i recently downloaded and installed a mingw 4.11 compiler
    i installed bloodsheds dev C++ 4.992
    i dont have SCons yet (just downloaded v1.20)
    do i need python to make VST plugins with ? (does that somehow help SCons?)
    i’m not aware of what scripting has to do with VST plugins ?
    im at the site downloading python 2.6.4 ATM

    as far as the other things i might need (vst host,text editor,command line tool?)
    i use fl studio, its an earlier version though it does load all my max/msp plugins fine.
    i mainly use notepad (even for html editing)

    i somehow feel that i might not have my codeblocks or dev C++ setup properly where
    the sdk files will compile correctly. one thing i tried earlier in dev C++, i saw
    that there were like 15 linker errors …. i can’t seem to figure out what went
    wrong when the messages were moderately vague at best. i hope i’m not badgering
    you too much with this? i’m just trying to get the understanding of what i have to
    do to make things work right and finally start building some VST synth plugins.

    • November 16, 2009 at 00:03

      No problems. I’m happy to try and help where I can. The easiest thing you can do to get building VST plugins is download Visual C++. I show people how to do the same here using GNU tools because I think it is more useful (especially for the complete newcomer) to see how things are all linked together. This way, you can then use this knowledge to build in other 3rd party libraries etc. with a bit of knowledge of how to link things together yourself. I find VS a bit daunting with all of its features and I found I never really learnt what was going on in the build when I just used the .vcproj files which set everything up for you.

      The only reason you need python here is because SCons runs on python and the build scripts are written in python. If you were to use code blocks, then you would not need python, or SCons, or a separate text editor as all of this (or the equivalent) is built into the IDE. I just show how you can use a bunch of separate tools here to do the same job as you can with an IDE.

  6. TinkRGnome
    November 17, 2009 at 05:24

    well hold on … i dont mind doing a lil work to build a VST plugin. you see i want to understand how the whole process works from start to finish. i can generally tell that the microsoft VC++ IDE prolly makes it a snap to do it. tho… i still need to install SP2 if i’m going to use something like vc++ 2005exp or 2008 for that matter. tho as far as all files included for things to work go,i realized a small quandry i fell into … i realized as of recent looking in both (2.3 & 2.4r2) the sdk zips, i read some info in a few places that i need to add extra lines/change a few of code to a file called “vstNameMain.cpp” and i dont have that source file. furthermore i need to understand exactly what files to add to the dev C++ or code::blocks editor and compiler settings, linker settings, just about every step imaginable to make a VST synth work.(preferably a one that could manipulate multiple oscillators…. 8/16/32 +) if i could please ask your help …. i’d be in your debt. btw i saw this page and wanted to show you as far as what i mentioned on the “some lines i read needed to be changed/edited” in the vstNameMain.cpp business.

    http://www.students.tut.fi/~paulus/vstsdk.html <— this person is talking about using dev c++ 4.98
    with use of sdk2.4 … tho i've looked in the zip… theres hardly any source files in there to begin with. unless this whole "vstNameMain.cpp" is a matter of something like……. "VST(the name you choose for the plugin)Main.cpp, otherwise if its properly titled "vstNameMain.cpp", i dont have it.

    1000 apologies for sounding completely hopeless/n00bish/lost/etc…. man, if only i could build these plugins in classic vb6…… life would be good. (even tho i understand VB6 can't)
    (sigh…..)

    • November 17, 2009 at 11:53

      Stop apologising calling yourself names, “hopeless/n00bish/lost/etc”. The only dumb questions are those not asked 🙂 I’m trying to learn too. I’ll have a look at getting this going on Code::blocks this evening if I get time.

  7. TinkRGnome
    November 19, 2009 at 02:28

    thanks B

    i would be grateful for any help you could provide me. i’ve got a few ideas on type of synths
    i’d like to build. that might not mean much ATM, though, upon building various stages of a synth i could get the largest view possible on how its done. to see what code does what. to understand how code inside the plugin is arranged, would give me a very nice sense of accomplishment.

    the ideas i have …

    1) a basic 3 oscillator synth w/ pitch adjustments & possibly onboard effects (flange/chorus..
    * or a similar synth with a standard 2 oscillator setup w/ a control that could select
    2 – 4 or more additional oscillators…

    2) a stepped up synth w/:
    * possibly 3/4/5 oscillators w/ waveshaping using a *.wav file (or 2)
    * onboard effects (flange/chorus/ringmod/comb/etc)
    * onboard filter shaping elements (volume/ADSR/etc)

    3) a drum machine possibly w/:
    * 4 – 8 onboard (*.wav) sounds as the drum kits
    * on boards filters or effects

    4) a modular synth like syd 1.07 ,…oh man i’d love to build a synth like that program,… its got some very smooth widgets on building/calculating resulting sounds. if you’re curious?
    for details on syd 1.07, see below:

    http://www.harmony-central.com/Software/Windows/syd.html
    http://www.jbum.com/syd/index.html

    5) a synth that can play soundfonts (*.sf2)… i don’t know why, though i do beleive that would be a nice idea for a synth.

    6) MIDI controllers … if steinberg gmbH/other people can make them (seemingly) in C/C++, i dont see why i couldn’t learn how to. (i’m not really sure how steinberg makes them or what language they use. its not very important/any of my business to know)

    i hope that doesn’t sound like too much to want all in one shot. i should have been starting
    to learn this kind of programming years ago.

  8. TinkRGnome
    November 19, 2009 at 03:05

    thanks B (i just tried to post a message earier but it didn’t seem to register on the board)

    i’d be grateful for all the help you could provide me. as i might have mentioned before i have some ideas for some different synths i’d like to build.

    1) a basic synth w/ frequency adjusts/envelopes/possibly onboard effects

    2) a drum machine w/ a few kits of *.wav sounds onboard & possibly controls to add user defined sounds w/ possibly some onboard effects/filters/etc.

    3) a waveshaping effect/sound mangler plugin that could be applied to a sample loaded in your sequencer.

    4) a synth that could connect various widgets (components) by virtual wiring to generate some experimental synth sounds

    5) a synth that can play soundfonts (*.sf2)

    6) a MIDI controller

    just to name a few ideas i’d like to create.

    • November 21, 2009 at 19:47

      Build again in code::blocks . . .

      1) Make new EMPTY project and call it “again” – you can save this anywhere on your system

      2) Assuming you have put the sdk at c:\vstsdk2.4, then right click on the project you have just created, select build options, got to the ‘search directories’ tab and add c:\vstsdk2.4 to the list.

      3) Right click on the project and select add files. Add the following:
      C:\vstsdk2.4\public.sdk\source\vst2.x\audioeffect.cpp
      C:\vstsdk2.4\public.sdk\source\vst2.x\audioeffectx.cpp
      C:\vstsdk2.4\public.sdk\source\vst2.x\vstplugmain.cpp
      C:\vstsdk2.4\public.sdk\samples\vst2.x\again\source\again.cpp
      C:\vstsdk2.4\public.sdk\samples\vst2.x\again\source\again.h

      4) Right click on the project, select ‘Properties’, navigate to the ‘Build targets’ tab and select ‘Dynamic library’ from the ‘Type’ drop down list.

      5) Build the project.

      • November 21, 2009 at 19:55

        I forgot to add, between stage 4 and 5 . . .

        Right click the project, select ‘Build options’ go to the linker settings tab and under ‘Other linker options’ add the following:
        -def C:\vstsdk2.4\public.sdk\samples\vst2.x\win\vstplug.def

  9. TinkRGnome
    November 22, 2009 at 06:22

    ok …

    i followed the instructions exactly to the letter. then i Drag & Dropped the plugin into my “vst” folder and was pleasantly surprised it worked. fantastic! thank you ever so much !! when i load the plugin into my sequenceer it displays the sequencers default UI,… that’s not a problem. i could soon hopefully do some looking in there to build some more projects daring
    as i might try. though, upon building it did give me the following warning :
    ****************************************************************************************
    ||=== again, Debug ===|
    C:\SDK24\public.sdk\samples\vst2.x\again\source\again.cpp|27|warning: multi-character character constant|
    ||=== Build finished: 0 errors, 1 warnings ===|
    in the again.cpp it placed the warning marker next to this entry in the source file:
    || setUniqueID (‘Gain’); // identify
    ****************************************************************************************
    i assume that i could ignore ‘most’ warnings… perhaps not all of them in terms of the project building. that makes me want to try the Adelay on my own now. i’ll add the following files with the instructions you’ve set forth & see if it works.
    ___________________________________________________________
    C:\sdk24\public.sdk\source\vst2.x\audioeffect.cpp
    C:\sdk24\public.sdk\source\vst2.x\audioeffectx.cpp
    C:\sdk24\public.sdk\source\vst2.x\vstplugmain.cpp
    C:\sdk24\public.sdk\samples\vst2.x\again\source\adelay.cpp
    C:\sdk24\public.sdk\samples\vst2.x\again\source\adelay.h
    ___________________________________________________________

    and i know i want to try to build a vstsynth (vstxsynth???) and try to develop a custom UI. also, if i wanted to add an effect to a synth if i could get it to work, i wondered if i could just add the effects source code to the vstxsynth.cpp, unless it doesn’t work that way (thinking of ye olde VB6 hehehehe) or if i should simply add the delay.cpp to the roster of files then add a reference to the synth in code to its *.cpp that activates or triggers a delay? correct me if i’m mistaken, i just looked at a few of the files within sdk2.4,……

    — *.H/*.HPP files (are like files that define the object(s) within the project ??)
    — *.C/*.CPP files (are like files that create the mechanics/features of the project ??)

    well aight B, i’ll give that Adelay a try and i’ll let you & everyone that frequents the site here know of my findings. if i can get it to work with your instructions as per the gain example, i’ll gladly post it.

    and thank you again.

  10. TinkRGnome
    November 22, 2009 at 20:02

    this just in…..

    last night i tried building the “adelay” with your same instructions only except i used a few different files….. i made changes to the instruction sheet for the delay plugin. i couldn’t
    beleive my ears at first,… i was like WOW, thats fantastic wow it sounds in my sequencer when i just apply it to a single drum sound playing.

    Build the “adelay” in code::blocks . . .

    1) Make new EMPTY project and call it “adelay” – you can save this anywhere on your HDD/system

    2) Assuming you have put the sdk at c:\vstsdk2.4, then right click on the project you have just created, select build options, got to the ’search directories’ tab and add

    c:\vstsdk2.4 to the list.

    3) Right click on the project and select add files. Add the following files:
    C:\vstsdk2.4\public.sdk\source\vst2.x\audioeffect.cpp
    C:\vstsdk2.4\public.sdk\source\vst2.x\audioeffectx.cpp
    C:\vstsdk2.4\public.sdk\source\vst2.x\vstplugmain.cpp
    C:\vstsdk2.4\public.sdk\samples\vst2.x\again\source\adelay.cpp
    C:\vstsdk2.4\public.sdk\samples\vst2.x\again\source\adelay.h
    C:\vstsdk2.4\public.sdk\samples\vst2.x\again\source\adelaymain.cpp ****
    **** —- i added the above file and it does not seem to cause any errors/warnings, though, i can’t tell if it does anything for the plugin ?

    4) Right click on the project, select ‘Properties’, navigate to the ‘Build targets’ tab and select ‘Dynamic library’ from the ‘Type’ drop down list.

    5) Right click the project, select ‘Build options’ go to the linker settings tab and under ‘Other linker options’ add the following:
    -def C:\sdk24\public.sdk\samples\vst2.x\win\vstplug.def

    6) Build the project.

    i can’t beleive how easy that was…. though, i’m sure the vstxsynth template will prove to
    be a tough one. enjoy !! and thnx again B.

    • November 22, 2009 at 20:40

      All the examples in the SDK should be easy to build according to these guidelines. The only one you’ll find a bit more tricky will be surrounddelay with its GUI. Just import the VS project into code::blocks and see the different settings needed under build options

  11. TinkRGnome
    November 23, 2009 at 00:31

    i just finished up building the vstxsynth .

    i first tried to import the ms visual studio project of it. i only had to remove the vstxsynth.rc
    and the vstxsynth.vstxml cuz codeclocks kept giving me an error everytime i tried in compiling/ rebuilding it, saying something about it couldn’t open the vstxsynth.vstxml so i just compiled it with the files that remained and it worked. and also i tried your instructions and built it from scratch. it was kinda hectic figuring a few things out but i got it. now if i could figure out how to enhance the synth or a synth variation of it from the 2 simple waveform selections it provides to add more to it…… that would be nice. i hope i’m not taking anything away from this tutorial,… i wasnt trying to. thouigh it seems i’ll have to look ahead in trying to build an advancement on this vstxsynth if i wish to someday build a unique/customized synth.

  12. TinkRGnome
    November 24, 2009 at 06:57

    i tried visiting a few forums in hopes i could gain some insight on altering these files where
    i could develop a custom synth out of it ,…. to no avail. i shouldn’t have bothered going to some place like KVR, i can’t seem to gain help from that place. it seems all they want to do is brush you off with a URL and close your topic if it’s something they really don’t want to press on with. i dont mean to sound disappointed/angry about it, i can’t help it. i dont want to sound like i’m badmouthing them either. i’m NOT trying to do that. but in order for me to build a custom synth…. like from scratch i had a thought i would really need to understand C/C++ language much better than i do (or don’t?) … sigh. i don’t want to spend 10 years in trying to figure it out. i tried altering copies of a few files i thought would bring about a necessary edit in the synth, though i can’t understand what to do really. for now i’d like to insert source code in the main file(s) to create a few different oscillators like a square/
    sine/triangle/etc. maybe create controls that could activate them separately/controls that could change each OSC’s frequency with a slider or knob, textbox… something. is it possible you could help me understand how to do these things, cuz i can’t seem to gain any help anywhere else. if you could please ? no pressure… i want to humbly thank you for the courage/confidence you gave me to try.

    it goes a long way. it really does.

    i just wish someone could post an archive of files where people could seriously learn by
    instruction aiding the source/header/other necessary items represented with a type of generic set of files then they could learn from, then how to customize with additional source code insertion with either code::blocks, dev c++, or any other IDE they choose.

    • November 24, 2009 at 12:47

      Hello again,
      I admire your persistence! I don’t know if you’ve seen my link on the other page, but one of the most completely basic starting tutorials is here:

      http://www.euphoriaaudio.com/tutorials/vstexample/vstexample1.php

      It can be quite difficult to find source code for really simple VST projects on the web, but there is mountains of stuff on generating different waveforms in C/C++. I was hoping that this site could become a good resource for source code to simple VST projects but I just haven’t had the time because of my current workload. I do wish to advance this site but I won’t be able to make any real effort until spring next year. Perhaps I should start a forum for this site so that people can help each other toy with the total basics before I start adding some more structured tutorials on some actual programming. The title of this site is a bit misleading at the moment, I must admit. There are just some build tutorials for using GNU tools and no actual “C++ VST plugin tutorials”. I do hope and wish to remedy this but my hands are tied at the moment.

      As a side note, you really really need to know the language well to implement new ideas. Perhaps reading “Numerical Recipies” will get you thinking along the right lines. See the link I posted about the SDL tutorials on the main page also. It’s not related to VST but the style is good – that is the kind of resource I’d like to turn this site into.

  13. TinkRGnome
    November 25, 2009 at 05:13

    thanks … i searched for a home site where numerical recipes were on … some interesting

    one thing tho, you mentioned:: bmoviehorror “………. See the link I posted about the SDL tutorials on the main page also. It’s not related to VST but the style is good – that is the kind of resource I’d like to turn this site into.” <—– this is shown on the euphoria website? or KVR ? not quite sure what you mean by it. i read thru both the vstexample and tremolo tutorial pages, it looks like they took the *.h & *.cpp and chopped them up as they spoke of them. the files i see are missing lines of sort as i look at them on those webpages, unless theres a place i can download both of them an give it a try. i was going to attempt the tremolo
    plugin. i have so far pieced together the 2 main source files needed to build it along with several other files i needed to find since i looked through the cmath.h (was a file codeblocks did not have) and found out i needed several other included files for it to work right.
    http://www.koders.com/ < —– i found them here

  14. Owen
    February 27, 2010 at 03:27

    Hi

    Just wanted to add, that installing Python 2.5 need not be ad complex as the system you have specified at the top of the page.

    Of course, it is good to work through things in as much detail as possible to learn what you can, but there is a really convenient installer available for a load of versions of Python.

    Active Python

    Check out this link here…

    http://www.activestate.com/activepython/

    Really good, and worked perfectly for me under XP.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: