VST instrument parameter recall

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi

I'm developing a VST2 instrument (Linux and Windows).

Everything works as expected but when I save plugin with the song and load the song, the parameters are not set by SetParameter calls by VST host and the user interface shows parameters in default positions when the editor is opened.

So I wonder if I should do GetParameter calls at some point when the instrument is initialized or how are saved parameters passed to the instrument by the host?

Post

Via effGetChunk and effSetChunk opcodes. It is a job of your plugin to serialize and deserialize parameter state and any other state.

Post

Vokbuz wrote: Thu Apr 09, 2020 3:34 pm Via effGetChunk and effSetChunk opcodes. It is a job of your plugin to serialize and deserialize parameter state and any other state.
Depends on whether you advertise chunks or not. If you don't advertise programsAreChunks() then the host should indeed call setParameter() for every parameter to restore the plugin state.

That said, for debugging this stuff, one might want to trace the actual setParameter() calls. You might also want to trace for setProgram() calls, since there is this whole mess with the "current program" vs. presets and make sure you don't overwrite the newly set parameters with some stale preset data.

Another thing to check is that you call setParameterAutomated properly whenever the parameters are changed. Some hosts might ask you for the parameter values when saving, but others might use their own internal cached values, which won't ever update unless you notify the host properly.

There could also be any number of other possible issues, but these would be the most obvious I can think of.

Post

Thank you.

Do you know where to find documentation for effGetChunk/effSetChunk?

Can the chunk be just array of parameters?

effGetChunk:

float* chunk = (float*)malloc(numParams*sizeof(float))

for(unsigned int i=0;i<numParams;i++)
chunk = parameterValue;

*pointer = chunk;
return sizeof(float)*numParams;

If the above code is correct, who does free() the chunk?


cslr

Post

rpls wrote: Thu Apr 09, 2020 6:26 pm Do you know where to find documentation for effGetChunk/effSetChunk?
Probably "nowhere" really, but these are the getChunk/setChunk methods if you have the SDK.
Can the chunk be just array of parameters?
A chunk can be basically anything you want. As far as the host is concerned, it's just an opaque piece of binary data that you store and which is returned to you to restore the state.

That said, it is a good idea to add some structure to your chunks, at least so you can sanity check that they are indeed valid chunks for you plugin. Some people use things like XML, but even if you choose to use a binary format, you might still want to add some header.
If the above code is correct, who does free() the chunk?
Your plugin should free the chunks that you allocate at some later point in time. For C++ plugins, probably the easiest approach is to store your chunks in std::vector<uint8_t> or something similar, which you can easily resize as required and which will get automatically disposed when your plugin is unloaded.

Post Reply

Return to “DSP and Plugin Development”