vst

How to get/set instrument loaded in Kontakt VSTi?


I've read the VST 2.4 SDK docs and the includes but still haven't found any way to do this:

When you instantiate Native Instruments Kontakt as a VSTi in a VST host app, such as Cubase, the host app is able to find out which instrument is loaded within the Kontakt VST window and it is able to restore that instrument (tell Kontakt to load it in itself) when a Cubase project is loaded. Cubase is even able to restore multiple instruments in a single Kontakt instance.

What API commands/events do they use for that? Or is there any proprietary way agreed between Steinberg and NI?

BTW, Kontakt is VST version 2.4 (not 3.x). Thanks.


Solution

  • Ok, I've managed to write code that does exactly what I needed:

    To obtain internal plugin state:

    if (pEffect->flags & effFlagsProgramChunks)
    {
        void *stateBuf = NULL;
    
        stateBufSize = (int) pEffect->dispatcher (pEffect, effGetChunk, 0, NULL, &stateBuf, 0);
    
        // ...
    }
    

    To set/restore internal plugin state:

    if (pEffect->flags & effFlagsProgramChunks)
    {
        pEffect->dispatcher (pEffect, effSetChunk, 0, (VstIntPtr) stateBufSize, stateBuf, 0);
    }