Your own editor

Previous | Next | Home

    Of course your VST plugin can look much better than the default editor that Cubase and most other hosts provide. How ? Create your own editor window to be shown by the VST host ! It's really not difficult.

    Take a look at doubler.zip. This example implements its own editor and should be very useful to start with.

AEffEditor

The first thing to do is create a new class derived from AEffEditor (ADoublerEditor in the example). This class provides the interface between VST and your own editor window. It provides a couple of methods for this purpose.

function getRect(var rect: PERect): longint;
This function gets called when VST wants to know the dimensions of your editor window. You need to return a pointer to an ERect structure in the rect parameter. The result of the function is 0 if you returned a valid record.

function open(ptr: pointer): longint;
In this function you have to create the editor window and assign it a parent handle. The parent handle is provided in the ptr parameter (which is not really a pointer but a THandle).

procedure close;
When this gets called, you destroy the editor window you've previously created.

procedure idle;
This procedure gets called when the user isn't doing anything. If you can think of anything useful to do at such a time, this is the place to do it. The standard behaviour (in AEffEditor) is to call the update procedure (see below).

procedure update;
When this gets called you can update the editor (just stating the obvious here). This procedure gets called when the updateFlag member of AEffEditor has been set to 1, for example by a call to postUpdate (see below).

procedure postUpdate;
This procedure sets the updateFlag member of AEffEditor to 1.

AEffEditor also has a couple of member variables :
effect : This is a pointer to your AEffect structure (passed to the constructor of your descendant of AEffEditor)
systemWindow : The handle of the parent window of the editor (you have to set this in the open function)
updateFlag : If this is one, the editor should be updated

Don't forget to look at the example code in Doubler, it will make things a lot clearer.

Loose ends
Now that you've created the editor class, it's time to let VST know that it exists. Just create an object of your editor class and assign it to the editor member of your plugin class (descendant of AudioEffect).

For example (in the constructor of ADoubler) :
editor := ADoublerEditor.Create(Self);

Of course, you still have to create the form for your editor to actually be visible to the user! Once again, take a look at the Doubler example to get started.