23.03.2015 Views

Plugin Consultant Guide

Plugin Consultant Guide

Plugin Consultant Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Plugin</strong> <strong>Consultant</strong> <strong>Guide</strong><br />

Copyright 2005 By Ofer Shem Tov<br />

<strong>Plugin</strong> <strong>Consultant</strong> is a tool for monitoring and logging VST API communication between<br />

VST hosts and VST plugins. It started as a debugging code inside another project but when<br />

I found out that I needed to repeat this code in many places and also needed more control<br />

over what is logged, I decided to create a standalone tool that can useful for every VST<br />

developer.<br />

Although <strong>Plugin</strong> <strong>Consultant</strong> is a simple to use tool, the following pages will explain it in<br />

more detail and will focus on some more advanced issues and tips.<br />

Since logging everything that passes between the host and plugin can sometimes generate<br />

be too much information or cause a performance depredation, you can control what is<br />

being logged.<br />

How does it work?<br />

<strong>Plugin</strong> <strong>Consultant</strong> is a DLL that exports the main() function, making VST hosts believe this<br />

is a VST plugin. When a host calls <strong>Plugin</strong> <strong>Consultant</strong>'s main() function, <strong>Plugin</strong> <strong>Consultant</strong><br />

ask the user to select a real VST DLL file. After the VST plugin DLL is selected, all VST API<br />

communication between the host and the plugin is proxied by <strong>Plugin</strong> <strong>Consultant</strong>. <strong>Plugin</strong><br />

<strong>Consultant</strong> does not change anything in the plugin or host behavior but it does watch all<br />

the VST API calls for monitoring and logging purposes.<br />

<strong>Plugin</strong> <strong>Consultant</strong> also proxies the plugin AEffect structure, meaning that all the plugin<br />

information (flags, number of programs, unique ID, etc.) is not changed by <strong>Plugin</strong><br />

<strong>Consultant</strong>. The only thing that might look different in the host when using <strong>Plugin</strong><br />

<strong>Consultant</strong>, is that the host shows the plugin as '<strong>Plugin</strong><strong>Consultant</strong>' and does not show the<br />

original plugin name.<br />

Since the VST plugin implements the editor GUI, <strong>Plugin</strong> <strong>Consultant</strong> user interface is<br />

displayed in its own separate window but it is still running in the host process.<br />

<strong>Plugin</strong> <strong>Consultant</strong> is using the VST C API (defined in AEffect.h and aeffectx.h) for<br />

monitoring and logging although most developers use the VST SDK C++ wrapper (defined<br />

in AudioEffect.hpp, audioeffectx.h and AEffEditor.hpp). This allows <strong>Plugin</strong> <strong>Consultant</strong> to be<br />

used with plugins or hosts that are developed in C, Delphi, SynthEdit and other languages<br />

or tools. More details about how to translate the C API to C++ will be provided later in this<br />

guide.<br />

Using <strong>Plugin</strong> <strong>Consultant</strong><br />

<strong>Plugin</strong> <strong>Consultant</strong> DLL Location<br />

For most hosts you should put the <strong>Plugin</strong> <strong>Consultant</strong> DLL in the VST folder used by the<br />

host so you can later select <strong>Plugin</strong> <strong>Consultant</strong> from within the host interface. Some hosts<br />

(e.g. energyXT, MiniHost and VSTHost) allow you to load plugins from any folder. Since<br />

you probably won't use <strong>Plugin</strong> <strong>Consultant</strong> on a daily basis you might want to put outside<br />

the VST folder until you need it to avoid some hosts from opening it each time they<br />

perform a plugin scan.


<strong>Plugin</strong> Scan<br />

Some hosts, such as Cubase, perform a plugin scan of the VST folder, usually when they<br />

start, and call the main() function of every plugin. If <strong>Plugin</strong> <strong>Consultant</strong> is located in the<br />

VST folder then it will ask for the VST plugin to log. You should select the same plugin that<br />

you are going to log later in the actual session since the host might store information<br />

about this plugin and this information should match the plugin that will be logged in the<br />

session. You can also see using <strong>Plugin</strong> <strong>Consultant</strong> log what the host actually does with the<br />

plugin in the plugin scan process. Some hosts will cache the scan information and will not<br />

load <strong>Plugin</strong> <strong>Consultant</strong> each time they start. In this case you will need to tell the host to<br />

re-scan the plugin folder before starting to log a new plugin.<br />

If you are using Cakewalk VST Adapter then the plugin scan happens when the adapter<br />

scans your VST plugins and not when a Cakewalk host starts. This mean that before a log<br />

session of a new plugin, you need to let the adapter scan <strong>Plugin</strong> <strong>Consultant</strong>, select the<br />

plugin to log, and only then run the Cakewalk host and use <strong>Plugin</strong> <strong>Consultant</strong> to log the<br />

same plugin you selected in the scan process.<br />

Selecting a <strong>Plugin</strong><br />

When you want to log a plugin you will need to load <strong>Plugin</strong> <strong>Consultant</strong> in your host. <strong>Plugin</strong><br />

<strong>Consultant</strong> looks to the host as the VST you selected when the host loaded <strong>Plugin</strong><br />

<strong>Consultant</strong> in the plugin scan. For example, in Cubase, if you selected an effect in the<br />

plugin scan then <strong>Plugin</strong> <strong>Consultant</strong> will appear in Cubase as an effect. If you selected an<br />

instrument in the plugin scan then <strong>Plugin</strong> <strong>Consultant</strong> will appear in Cubase as an<br />

instrument.<br />

Some hosts do not do a plugin scan and do not call main() function of the DLLs in the<br />

plugin folder. In these hosts the plugins will not be identified as effects or instruments<br />

since the main() function needs to be called in order to get this information. In other hosts<br />

you can even load a plugin by providing a DLL file name or by dropping the plugin DLL file<br />

on the host. With these hosts you can just select to load <strong>Plugin</strong> <strong>Consultant</strong> or<br />

<strong>Plugin</strong><strong>Consultant</strong>.DLL file.<br />

Once <strong>Plugin</strong> <strong>Consultant</strong> is loaded by the host it will ask you to choose a VST plugin DLL file<br />

to log. After you select a VST plugin the logged plugin will load as usual (although its name<br />

will appear as <strong>Plugin</strong><strong>Consultant</strong>) and you can use it and use its GUI (if it has one). In<br />

addition the <strong>Plugin</strong> <strong>Consultant</strong> window will appear as a different application in the Windows


taskbar. You cannot close <strong>Plugin</strong> <strong>Consultant</strong> window manually, it will close automatically<br />

when the logged plugin is unloaded by the host.<br />

<strong>Plugin</strong> <strong>Consultant</strong> Window<br />

On the top of the <strong>Plugin</strong> <strong>Consultant</strong> window you can see in the title bar the name of the<br />

VST DLL being logged. On the top right there is a minimize button for minimizing the<br />

<strong>Plugin</strong> <strong>Consultant</strong> window, you can always restore the window by clicking on the <strong>Plugin</strong><br />

<strong>Consultant</strong> taskbar icon.<br />

On the main part of the window you can view one of the 3 VST API categories (more on<br />

that in the Monitoring section) by clicking on categories tabs.<br />

To the left there are several buttons to control the monitoring and logging, a help button<br />

to view this guide, a logo that also opens the About dialog and a useful Donate button!<br />

Monitoring<br />

<strong>Plugin</strong> <strong>Consultant</strong> monitors all VST API calls between the plugin and the host and displays<br />

in real time what functions and opcodes were used in the session and how many times<br />

they were called. In addition you can see the log of all the calls, more details on that in the<br />

Logging section.<br />

The Reset Counters button resets all the function and opcodes counters and makes all the<br />

function and opcodes look like they were not called so far. This is useful when you want to<br />

see if a certain function or opcode is called in a certain scenario and you don't care about<br />

previous calls.<br />

A Time Display button bellow the Reset Counters shows how much time passed since the<br />

logged plugin was loaded, it can be reset back to zero by clicking it.<br />

You can switch between different the VST API categories pages, to monitor different parts<br />

of the API, by clicking on the categories tabs.<br />

AEffect Page


This page displays the AEffect structure that is returned to the host from the plugin main()<br />

function. The 6 VST C API function are highlighted when called for the first time and a<br />

counter shows how many time each function was called. 4 of the C functions are similar to<br />

the AEffect class C++ methods (process, processReplacing, setParameter and<br />

getParameter) and the other two are used to dispatch opcodes from the host to the plugin<br />

(dispatcher) or from the plugin to the host (audioMaster). The AudioEffect and<br />

AudioEffectX classes implement these functions for you in the C++ VST SDK and convert<br />

the opcodes to C++ methods, usually with names similar to the opcodes names. For more<br />

details about opcodes see the Dispatcher and AudioMaster sections.<br />

The logged plugin AEffect structure data members are also displayed in this page The<br />

AEffect structure display is refreshed (if changed) every time the plugin calls the host since<br />

it might have changed parameters, for example when the plugin calls ioChanged().<br />

Dispatcher OpCodes Page


This page displays the opcodes that are sent from the host to the plugin via the<br />

dispatcher() function. The opcodes are displayed without the 'eff' prefix, for example<br />

effOpen is displayed as Open. If you use the C++ SDK then the AudioEffect class invokes<br />

the open() method when the effOpen opcode is sent by the host via the dispatcher()<br />

function. Usually the effXXX opcodes (displayed as XXX in this page) will invoke a method<br />

named XXX in the AudioEffect class. There are some exceptions to this, most important is<br />

the effMainsChanged opcode that invokes the suspend() and resume() methods,<br />

depending on a parameter sent by the host. You will need to see the log in order to know if<br />

the host requires the plugin to suspend or resume.<br />

Opcodes sent for the GUI editor have 'effEdit' as a prefix, for example effEditOpen will<br />

invoke the open() method of the AEffEditor class and will be displayed in this page as<br />

EditOpen.<br />

The opcode names are ordered in the same order they appear in the AEffect.h and<br />

affectx.h.<br />

AudioMaster OpCodes Page


This page displays the opcodes that are sent from the plugin to the host via the<br />

audioMaster callback. The opcodes are displayed without the 'audioMaster' prefix, for<br />

example audioMasterVersion is displayed as Version. If you use the C++ SDK then the<br />

AudioEffect and AudioEffectX classes sometimes provide method that hide these details<br />

from the programmer. For example the getMasterVersion() will send the<br />

audioMasterVersion opcode to the host.<br />

The opcode names are ordered in the same order they appear in the AEffect.h and<br />

affectx.h.<br />

Logging<br />

<strong>Plugin</strong> <strong>Consultant</strong> logs all the communication between the host and the plugin using the<br />

Win32 OutputDebugString function. In order to view the log you will need to an application<br />

that displays Windows debug output, or view the log within your development<br />

environment. Examples of both options are described later in this section.<br />

Since logging all host-plugin communication can sometimes generate too much<br />

information and cause performance depredation, you can control what is logged.<br />

Left to each function or opcode name there is a light that shows if this function or opcode<br />

is logged. You can click the function or opcode name to toggle logging on/off. Note that


that turning off logging for the dispatcher function in the AEffect page will turn off logging<br />

for all the opcodes in the Dispatcher OpCodes page, even if the light left to the opcodes is<br />

on. In the same way, turning off logging for the audioMaster function will turn off logging<br />

for all the opcodes in the AudioMaster OpCodes page.<br />

The Enable All button turns logging on for all functions and opcodes in all pages. The<br />

Disable All button turns logging off for all functions and opcodes in all pages. The Inverse<br />

All will toggle the logging on/off state for all functions and opcodes in all pages.<br />

Clicking the Time Display button, in addition to reseting the time display, will also send a<br />

log line stating that the time was reset: "<strong>Plugin</strong><strong>Consultant</strong> timer reset after XXX secs".<br />

The Stop Logging button will stop all log output, even if logging is on for specific functions<br />

or opcodes. The button will then turn into a Start Logging button that will enable logging<br />

again when clicked.<br />

Log Output Format<br />

<strong>Plugin</strong> <strong>Consultant</strong> log will always start with the name of <strong>Plugin</strong> <strong>Consultant</strong> DLL and the time<br />

when the log was started.<br />

(3324) <strong>Plugin</strong><strong>Consultant</strong>.dll:<strong>Plugin</strong> <strong>Consultant</strong> - <strong>Plugin</strong><strong>Consultant</strong>.dll<br />

(3324) <strong>Plugin</strong><strong>Consultant</strong>.dll:22 May 2005 11:47:01 am<br />

A log line will always start with the ID thread of the current thread followed by the name of<br />

the logged plugin DLL name, for example:<br />

(2152) V-Station.dll:Loaded V-Station.dll<br />

(3036) V-Station.dll:DLL_THREAD_ATTACH<br />

Note that the log viewer might add its own information before each <strong>Plugin</strong> <strong>Consultant</strong> log<br />

line, for example: current time, process ID, etc.<br />

Functions and opcodes are logged with their parameters (both input and output) names<br />

and value, if they have any.<br />

Example of opcode without parameters or return value:<br />

(2152) V-Station.dll:effOpen


Example of opcode with parameters (this opcodes invokes the resume method in the C++<br />

SDK):<br />

(2152) V-Station.dll:effMainsChanged state=1<br />

Example of opcode with return values:<br />

(2152) V-Station.dll:effGetProductString<br />

(2152) V-Station.dll:effGetProductString returned bool=1 text=V-Station<br />

Examples of opcode with both parameters and return values:<br />

(5184) energyXT.dll:effCanDo text=midiProgramNames<br />

(5184) energyXT.dll:effCanDo returned long=0<br />

Note that char* parameters are displayed as a text string. Structures and buffers pointers<br />

are currently displayed as pointers only and without the structure or buffer contents:<br />

(5184) energyXT.dll:effGetOutputProperties index=0 properties=0012F494<br />

You can turn off logging of input or output parameters using the Log Parameters and Log<br />

Return Parameters check boxes.<br />

Logging with DebugView<br />

Note: Although this section describes working with DebugView, other debug output<br />

viewers can be used as well and will probably provide similar functionality.<br />

DebugView is a free Windows applications that lets you monitor debug output. You you<br />

need such an application when you are not using a debugger but you still want to capture<br />

the <strong>Plugin</strong> <strong>Consultant</strong> log. Remember to run DebugView before you start the <strong>Plugin</strong><br />

<strong>Consultant</strong> session so you will be able to see all logs from the beginning of the sessions.<br />

Also make sure the Capture Win32 option is checked.


Note that DebugView adds its own fields in the log, before <strong>Plugin</strong> <strong>Consultant</strong> fields: log line<br />

serial number, log time and process ID.<br />

You can also use DebugView filtering feature to filter the log output or highlight specific log<br />

lines. Its recommended not to use DebugView to filter out specific opcodes or functions<br />

since doing so using <strong>Plugin</strong> <strong>Consultant</strong> control will give much better performance.<br />

Logging with Visual C++ 2005 Express Edition<br />

Note: Although this section describes working with Visual C++ 2005 Express Edition, other<br />

development environments can be used as well and will probably provide similar<br />

functionality.<br />

When you debug your plugin or host with Visual C++ 2005 Express Edition you will be able<br />

to view <strong>Plugin</strong> <strong>Consultant</strong> log output in the Visual C++ Output window. Visual C++ might<br />

add some additional log output of its own, usually describing thread and DLL events. You<br />

can identify <strong>Plugin</strong> <strong>Consultant</strong> logs by identifying the VST DLL name being logged. Visual<br />

C++ does not add additional information to <strong>Plugin</strong> <strong>Consultant</strong> log output.


Using Multiple Instances<br />

<strong>Plugin</strong> <strong>Consultant</strong> does not allow itself to be loaded more than one time in the same<br />

process. Running <strong>Plugin</strong> <strong>Consultant</strong> in multiple processes in the same time can also be a<br />

problem since all the preferences are saved in an XML file when <strong>Plugin</strong> <strong>Consultant</strong> is closed<br />

so you won't be able to keep the preferences for the different logging sessions.<br />

To overcome those issues, you can easily create multiple instances of <strong>Plugin</strong> <strong>Consultant</strong> by<br />

copying the <strong>Plugin</strong><strong>Consultant</strong>.DLL file to new files with different names, for example<br />

<strong>Plugin</strong><strong>Consultant</strong>MySynth.DLL and <strong>Plugin</strong><strong>Consultant</strong>MyEffect.DLL. Since the XML<br />

preferences file name is based on the DLL name, each instance will create its own XML file<br />

so the preferences will be saved per instance, for example <strong>Plugin</strong><strong>Consultant</strong>MySynth.XML<br />

and <strong>Plugin</strong><strong>Consultant</strong>MyEffect.XML.<br />

There are several benefits for using this method to create multiple instances of <strong>Plugin</strong><br />

<strong>Consultant</strong>:<br />

• You can log multiple VST plugins in the same host and in the same time<br />

• You can have kind of 'presets' of different preferences for different type of logging<br />

sessions (logging only editor stuff, only audio stuff, etc.)<br />

• You can avoid the need to perform full plugin re-scan in hosts like Cubase each<br />

time you want to log another plugin, just prepare multiple instances, one for each<br />

plugin, and perform only one plugin scan to set things up


Performance Issues<br />

<strong>Plugin</strong> <strong>Consultant</strong> does not take a lot of CPU when monitoring the VST API since it does not<br />

perform almost any logic for each call and the GUI is running in another thread and<br />

updated using a timer. You should not experience any performance degradation or audio<br />

problem when you only monitor the API (i.e. all logs are turned off).<br />

However, logging can take a lot of CPU, from causing some audio problems to a complete<br />

freeze of a system. Most of the CPU is taken by the log output viewer and not by <strong>Plugin</strong><br />

<strong>Consultant</strong> but even without an active debug output viewer there might be some issues<br />

with the audio quality.<br />

In order to reduce the CPU hit you can use <strong>Plugin</strong> <strong>Consultant</strong> GUI and turn off logging for<br />

frequently called functions and opcodes that you do not need to log. Frequently called<br />

functions and opcodes include process, processReplacing, ProcessEvents, EditIdle and<br />

others. Since different hosts and plugins can frequently call additional functions or<br />

opcodes, you can use <strong>Plugin</strong> <strong>Consultant</strong> to understand which are these by seeing the<br />

counters for these advance quickly. Note that audioMaster and dispatcher counters might<br />

advance quickly but since these are dispatching function you can go to the relevant page<br />

and turn logging off for the relevant opcodes and not for all plugin or host opcodes.<br />

If you must log a frequently called function like processReplacing you can try and add to<br />

your sound card buffer size since many hosts use this buffer size as the buffer size for the<br />

audio and midi calls. For example if the buffer size is 2ms then the processReplacing<br />

function will be called 500 times in one second but if you make it 100ms then it will be<br />

called only 10 times in one second. You can use larger buffers when debugging and later<br />

restore to normal latency when you turn off the logging for the audio and midi functions<br />

and opcodes.<br />

In case the host or the system freezes because of too much CPU taken by <strong>Plugin</strong><br />

<strong>Consultant</strong> logging and you cannot even access the <strong>Plugin</strong> <strong>Consultant</strong> GUI, try to edit the<br />

<strong>Plugin</strong><strong>Consultant</strong>.XML file with a text editor and turn off the offending function or function<br />

log. Save the XML file and the next time you start <strong>Plugin</strong> <strong>Consultant</strong>, it will use the<br />

changed preferences from the XML file. The XML file format is self explanatory.<br />

Copyright 2005 By Ofer Shem Tov

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!