Euphoria Audio, LLC

Audio, Video and Data Consulting

Steinberg Example VST Plugin Walkthrough

No Comments »

bool AGain::getEffectName ( char * name)
{
    strcpy (name, "Gain");
    return true ;
} 

Next, the getEffectName function returns a name for the plugin that the GUI can display. The ‘return true' statement simply says that this function has completed it's goal.

bool AGain::getProductString ( char * text)
{
    strcpy (text, "Gain");
    return true ;
} 

Steinberg asks for each plugin to be registered with their web site and when you fill out the registration form you get a short identifying string to make your plugin unique. If you receive one of these strings you insert it here in the place of “Gain”. It does not affect the operation of your plugin but having a product string is a nice finishing touch once your plugin is working.

bool AGain::getVendorString ( char * text)
{
    strcpy (text, "Steinberg Media Technologies");
    return true ;
} 

For more identification you can provide your name or the name of your company using this function. Some hosts will check the product string and vendor string when cataloging and organizing plugins so the end user may see this information.

void AGain::process ( float **inputs, float **outputs, long sampleFrames)
{
    float *in1 = inputs[0];
    float *in2 = inputs[1];
    float *out1 = outputs[0];
    float *out2 = outputs[1];

    while (--sampleFrames >= 0)
    {
        (*out1++) += (*in1++) * fGain; // accumulating
        (*out2++) += (*in2++) * fGain;
    }
} 

Finally we come to the heart of the plugin where the actual audio processing occurs. Line 95 defines the process function and accepts input and output array pointers and a long value called “sampleFrames”. The two arrays are our buffers of audio samples and their size (how many samples the buffers hold) is determined by the “sampleFrames” value. We can use the “sampleFrames” value to determine when we've run out of samples and when to stop processing. Lines 97 through 100 create local pointer variables that point to the memory address of the left and right input and output buffers. These local pointers will be used to step through the buffer arrays. Line 102 sets up a While loop. Any processes within the loop will repeat until the conditions set in the parameter of the loop are met. In this case each iteration of the loop decrements the local “sampleFrames” value until it becomes -1. At this point the loop quits and processing continues to the next step which is to exit the function. Each iteration of the loop alters the actual values held in the audio buffers. Line 104 and 105 are similar, only they act on different audio channels. Each line is processed using the order of precedence defined by C++. First the pointer “*out” is resolved to read its value which is usually a 0 or null on the first iteration. Next we resolve the pointer “*in” to read its value which is a floating point number representing the amplitude of the current audio sample. Then the value represented by “*in” is multiplied by our “fGain” value (the floating point value set by our user in the GUI). Next the “*out” value is added to the modified “*in” value. Then the “*out” value is replaced by the sum of the “*out” value and the modified “*in” value. Then the “*out” and “*in” pointer addresses are incremented to read the next buffer sample and the iteration is finished. Once “sampleFrames” reaches -1, all of the iterations are finished and the output buffer is returned to the host via “*out” and our function is called again to read the next buffer. Following the process function is the processReplacing function that performs exactly the same steps as process() except that instead of adding the value of the “*out” pointer to the “*in” pointer in each iteration it simply replaces the “*out” value with the modified “*in” value. This will allow the plugin to be used as an insert effect. Now that you have seen how the AGain example plugin works, lets take a look at the modifications we made to create the tremolo plugin. To view the complete paper featuring the AGAIN walkthrough and the TREMOLO plugin, plus mathematical derivations and more detail, download this PDF file of my paper.

EA Tremolo Paper.pdf

Additional Resources

Pages:  1   2   3   4   5 

Leave a Reply