Mar 162009
 

The IPlug framework has a convenient way to manage your VST plugin’s version numbers. By design though, these version numbers only print out to the last non-zero digit. So a VST plugin at development version 1.0.0 will print as v1. I’d rather have it at least print the first digit after the decimal instead of losing it if they are all zeros. Read on to find out how to make that mod.

To define your VST plugin’s version number you can use the following c++ preprocessor define:

#define PLUG_VER 0x00010000

The version number can be interpreted with the first four digits representing the major revision number, the next two digits are the minor revision number, and the last two digits are the tertiary revision number. The revision number in the code sample above is equivalent to v1.0.0 which can be retrieved by calling GetEffectVersion or GetEffectVersionStr, both members of IPlugBase and are always available from within your plugin. Tracing back through GetEffectVersionStr leads us to GetVersionStr defined in IPlugBase.cpp around line 30.

void GetVersionStr(int version, char* str)
{
    int ver, rmaj, rmin;
    GetVersionParts(version, &ver, &rmaj, &rmin);
    if (rmin){
        sprintf(str, "v%d.%d.%d", ver, rmaj, rmin);
    }
    else if (rmaj) {
        sprintf(str, "v%d.%d", ver, rmaj);
    }
    else {
        sprintf(str, "v%d", ver);
    }
}

From this code it is easy to see why the trailing zeroes are chopped off via the cascading conditionals. I am going to modify the code so revision 1.0.0 will print as 1.0 (still leaving off the final zero). To do that we only need to eliminate the third case and eliminate the conditional from the second case. Here’s the modified code.

void GetVersionStr(int version, char* str)
{
    int ver, rmaj, rmin;
    GetVersionParts(version, &ver, &rmaj, &rmin);
    if (rmin){
        sprintf(str, "v%d.%d.%d", ver, rmaj, rmin);
    }
    else {
        sprintf(str, "v%d.%d", ver, rmaj);
    }
}

Now my version numbers will print the way I want them to. Hopefully it makes sense for how to alter this code to affect the way your version numbers print.

Have fun developing your VST plugins!

Sorry, the comment form is closed at this time.