0

I'm trying to make a program that saves information about a given VST plugin to a file, in order to assist with categorisation of VST plugins. I found a simple host for loading each plugin in Windows, but I can't seem to write to files from the host program once a plugin's editor window has been opened.

For the VST host, I'm using this code from GitHub:

https://gist.github.com/t-mat/206e3e7dfc3f89421bc1

I have also tried writing my own host by following this tutorial, and I encountered the same issue.

Here is the test code I'm using to try and write to a file (replaces the main() function in the GitHub link above):

int main() {
    VstPlugin vstPlugin{ L"C:\\VSTNameHere.dll", GetConsoleWindow() };

    std::cout << "Saving file...";
    std::ofstream myfile;
    myfile.open("test.txt");
    myfile << "Test output.\n";
    myfile.close();
}

If I comment out the vstPlugin instantiation, the file saves. When I leave it in, however, I only see the 'Saving file...' message in the console and no file is created.

At this point I've narrowed down which section of the VST plugin initialisation is stopping files from saving, as it works when I remove the code that gets the editor window handle provided by the plugin and creates a window:

dispatcher(effEditOpen, 0, 0, editorHwnd);
RECT rc{};
ERect* erc = nullptr;
dispatcher(effEditGetRect, 0, 0, &erc);
rc.left = erc->left;
rc.top = erc->top;
rc.right = erc->right;
rc.bottom = erc->bottom;
resizeEditor(rc);
ShowWindow(editorHwnd, SW_SHOW);

If I was just storing information returned by the plugin (for example, the value of effFlagsHasEditor or effFlagsIsSynth) then removing this code wouldn't be a problem, but I'd like to be able to open the editor window as well so I can save a screenshot of it. Why won't files save once the editor window has been opened?

  • "My code doesn't work when I call this other code that we're not looking at." -- that's basically what you're saying. In that light, the advise is clear: Look at that code, it seems to cause problems. Two additional things I'd try though: Open the file before calling the suspect code or open the file with an absolute path. That said, welcome to SO! Please take the [tour] and read [ask] as a new user here. – Ulrich Eckhardt Aug 09 '19 at 06:10
  • Thanks! I provided a link to the plugin host's code in my question, and included the the snippet of code that seems to be causing the issue. The only thing that can't necessarily be looked at is 'effEditOpen' from the actual VST plugin, but I've tried this with multiple plugins (Dexed, Synth1, V-Station) and encountered the same issue. It also doesn't work if I try writing to the file before loading the plugin/using an absolute path. – Jarnarvious Aug 09 '19 at 19:58
  • Perhaps an issue with the host, also VST 2.x is way old. – Michael Chourdakis Aug 15 '19 at 12:57

0 Answers0