Determine the currently selected program when Editor is opened

Topics: Editor UI, Getting Started
Mar 7, 2012 at 7:59 PM

Firstly, a big thank you for putting VST.NET together. It seems excellent so far and has certainly made my life a lot easier.

I'm trying to determine which program is currently selected when the user opens up the Editor UI window. I can't seem to figure out a way to do this. I hope it's possible or I'll need to do some major rethinking in terms of program structure.

Many thanks,


Mar 7, 2012 at 9:30 PM

Seems adding "public void SetProgram(int programNumber)" to the PluginCommandStub class does what I need.

Mar 8, 2012 at 9:25 AM

"Normally" a host would call the SetProgram(int) method in order to 'initialize' the plugin to a new program.

Assuming you are using the Jacobi.Vst.Framework - if not - you need to keep track of the active program yourself.

The Framework looks for an implementation of the IVstPluginPrograms interface by calling GetInstance<IVstPluginPrograms> on your plugin root object. Return this object from the CreatePrograms method on the plugin root object or interface manager.

You can implement it by deriving from VstPluginProgramsBase (in the Plugin namespace) where you'd only have to implement one method to populate the collection with programs. This base class has an ActiveProgram property that will by default return the first Program in the list when no ActiveProgram was set (SetProgram will do that).

Your UI can also use the same property as its active program. If you should change the active program in your editor UI, you should call UpdateDisplay on the IVstHostShell interface. Retrieve this interface by calling GetInstance<IVstHostShell>() on the host parameter that was passed to you in the Open call.

Hope it helps,

Mar 8, 2012 at 9:51 AM

Very useful info Marc. Thanks for the prompt response.