Programmatically get the file path of a file bundled with a VST3 plugin?

I’m creating a VST3 virtual instrument and I want to ship it with some static configuration files (think: string tensions, etc.) that I want to read on my plugin’s initialization, as opposed to hardcode them.

I have managed to ensure these files are installed by adding them to
smtg_target_add_plugin_snapshots but, when I read them, how do I know the file path to read from? Can I assume a working directory? Is there an API function to get the path for resources? Is there a mechanism to read bundle files with VST3 plugins? I imagine there is as most virtual instruments will ship with samples.

I spent all day browsing the SDK to no avail…

1 Like

First use smtg_target_add_plugin_resources instead of smtg_target_add_plugin_snapshots. The following will put the files inside a folder named Configuration inside Resources directory:

smtg_target_add_plugin_resources(MyInstrument
        RESOURCES
            "path/to/file1.conf"
            "path/to/file2.conf"
        OUTPUT_SUBDIRECTORY
            "Configuration"
    )

Now to use those files from within the plugin you’ll need Steinberg::tchar gPath[VST_MAX_PATH] defined in dllmain.cpp or macmain.cpp. On Windows it will point to the path of your DLL e.g
“path/to/MyInstrument/x86_64-win/MyInstrument.dll”. But on MacOS it will point to the path of the bundle e.g “path/to/MyInstrument.bundle”. From this point you can modify the path to access your files.

2 Likes

Hi! I have exactly the same question.

However do not fully understand @gzperra’s answer as gPath is defined statically inside dllmain.cpp or macmain.cpp, isnt’t it? So how can I access from my plugin code?

@mxklabs did you find a way to do it via the SDK?

Many many thanks,
Luis.

{
// something like this

#if SMTG_OS_WINDOWS
extern Steinberg::tchar gPath;
#elif SMTG_OS_MACOS
extern char gPath;
#endif

//…
}