This project has moved and is read-only. For the latest updates, please go here.

Host Program change

Topics: Plugin Programs
Nov 25, 2012 at 2:28 PM

Hi Marc,

I thought I had this working but spotted it late, I'm trying to get my plugins to select the initial program number as set by the host - I have 30 programs returned correctly by my CreateProgramCollection. I was then expecting the ActiveProgram to be changed by the host when a user selects a different prog.

At startup Ableton seems to step through all 30 programs calling SetProgram in the command stub which then changes the ActiveProgram. Once this is done any new selections are bubbled through correctly.

Any ideas how I can 'ignore' this initial list walk - or does this sound completely wrong; in which case I've probably broken something fundamental ?

Kind regards



Nov 25, 2012 at 7:08 PM

I think you have to call the UpdateDisplay method on the host shell interface (IvstHostShell) after you've changed the active program.

Call GetInstance<IVstHostShell>() on the Host parameter that is passed to the plugin Open method (and stored as the Host property on the Plugin root class).


Hope it helps,

Nov 26, 2012 at 12:04 AM

Thanks Marc,

for some reason when Ableton creates my plugin it gets my program list from PluginPrograms and then steps through them all - call SetProgram for each on. It doesn't seem to be happening with anything else; I'll seek out some help from the Ableton community.

Sorry for asking these daft questions; these are obviously Daw product and Steinberg issues; I really should re-read the VST interface docs and learn this stuff myself.

Many thanks again.

Nov 28, 2012 at 2:41 PM

Ah, I thought I'd escaped this one but it is back. It isn't a problem that's stopping me but it'll certainly be a pain in the future - and appears to affect the samples too.

I don't suppose you have Ableton in your armoury - your seem to have everything hidden around you :) I wonder, if you don't whether one of your Followers does ?

Also, did you have another go at joining the Roland Javelin group; just as a matter of interest ?


Kind regards

Nov 28, 2012 at 4:45 PM

I just reread the thread and perhaps I'm not getting the problem you're having.

So the host walks through all you Programs - making each one active, then going on to the next.

So far it should not be a problem. I've heard that hosts do this to build a list or something they can show the user.

What happens when the walk is done. Which Program is selected? or does it stay on the last one?

In the first post you say "I was then expecting the ActiveProgram to be changed by the host when a user selects a different prog."

Where does the user select the new Program? If it is 'inside' your plugin, you have to set the ActiveProgram and then call the UpdateDisplay method on the HostShell interface.

If it is in the host, the host should call the SetProgram method - resulting in a new ActiveProgram which should trigger an event in your plugin to reinit the UI - reflecting the changes and to initialize the processing components with the new parameter values. If you're using the parameter manager class it should fire an event for each parameter that has changed.

Nov 29, 2012 at 12:56 AM

Yeah I didn't explain that very well.

When I load my plugin to a new track then everything is working correctly.

When I save that plugin as a project / live set, close and reload the set I get an exception in both StdPluginCommandStub.GetProgramNameIndexed and StdPluginCommandStub.SetProgram - because pluginPrograms is being returned with a count of 0.

I'm trying to debug it but it's being a pig; my VS 2012 isn't being kind.


Nov 29, 2012 at 1:02 AM

Oh its doing the same with MidiNoteMapper too; I wonder whether this is just a debugger thing; I'll have to try that after some sleep.


Nov 29, 2012 at 1:05 AM

And :)

FL Studio seems to do the same thing too; I thought I'd escaped it but my debugger issue is masking some of the problem.

Nov 29, 2012 at 7:03 AM

[looking at the source code]

The CreateProgramCollection method is called the first time the Programs collection is accessed. So they should be there when the 'anything' accesses programs...?

 "because pluginPrograms is being returned with a count of 0."

You mean the IVstPluginPrograms instance is not null but the Programs collection is empty - right? -or- is the returned IVstPluginPrograms instance null?

Yeah, sleeping on it is a good idea. Fresh mornings often hold simple solutions. ;-) I'll see if I can reproduce this problem at home.

Dec 2, 2012 at 8:17 PM

Ah, if only sleep had helped :)

Yes indeed, the collection is initialised but empty. I worded a hack to get it working but that's not good is it !

From what I can guess - in my cold fuelled haze - that Ableton (or whatever) is holding a copy of the programs list for itself when the Live Set / project is saved and isn't therefore calling into the Plugin first before stepping through.

Actually that doesn't make sense but I'll try again on the morrow - I can see a big piece of paper, a pen, a debugger and some lemsip in my future.

Many thanks Marc.

Dec 2, 2012 at 9:06 PM

That was quick.....

Some more definitive tests -

Firstly, this is an empty Ableton Live Set- I simply add a new instance of my plugin and the steps are as follows :-

  CreateProgramCollection (called from StdPluginCommandStub.GetPluginInfo >_pluginCtx.PluginInfo)
  StdPluginCommandStub.SetProgram ( called per program - in my case 30 + 1 ; zeroed at end of list )

Now, restarting with an empty Ableton Live Set, loading my saved Live Set (which is just my plugin from above).

  CreateProgramCollection (called from StdPluginCommandStub.GetPluginInfo >_pluginCtx.PluginInfo)

  StdPluginCommandStub.SetProgram ; Exception raised - pluginPrograms.Programs is initialised but count is 0

StdPluginCommandStub.GetProgramNameIndexed doesn't get called this time and the plugin programs are gone.

I guess either there are 2 instances of the plugin flying about or the PluginInfo is being trashed. I'll focus on this area in detail.


Dec 3, 2012 at 6:36 AM

So why does CreateProgramCollection return an empty list? That is your code ;-)


When I look at the Delay sample plugin (PluginPrograms.cs) that implementation will always return a filled collection. Did you say this plugin shows the same problems?

BTW: I totally forgot to look at the issue at home. I'm so wrapped up in right now. :-)

Dec 3, 2012 at 10:07 AM

OK, the host is calling StdPlugCommandStub.SetChunk - data is initialised but empty and isPreset is false, so the ActiveProgram is nulled and the programs are cleared.

That's the source, now to work out the cause.


And yes, Delay exhibits the same functionality.

Dec 3, 2012 at 10:36 AM

Ah, so the Host hands the plugin an empty chunk!?

There is also a method Called CanReadChunk on the IVstPluginPersistance interface. Can you see if that gets called? The default impl always returns true. There is an ElementCount on the structure that is passed as a param. Perhaps we could return something like (in your override)

return (chunkInfo.ElementCount  != 0);

I could also write some extra code to make sure ALL programs are always available after setchunk is called - even with a different number of programs in the bank (isPreset = false)...

Could also be handy for when you upgrade your plugin to a newer version, but get handed a chunk serialized from an older version.

Thanks so much for debugging this ;-)

Dec 3, 2012 at 11:23 AM

That's the least I could do. Actually that's the Most I could do; that's a silly phrase !

I'll have a look at ChunkInfo now and update you later.

Dec 6, 2012 at 9:43 AM

Hi Adrian,

I have some trouble debugging this but I have made changes to the SetChunk method that 'should' handle chunks with different sizes more gracefully.

You have to get the source code and build it yourself to test this change. See also: Building the Source Code.

Hope it helps.

Dec 6, 2012 at 11:11 AM

Great stuff, I'll download your update now.


Many thanks