我正在尝试使用 SDK 中包含的 VST 托管实用程序来加载插件。代码如图:
#include "vst/v3/Vst3CommonIncludes.h"
int main()
{
std::string vst3_module_path = R"(C:\Program Files\Common Files\VST3\Kontakt.vst3)";
std::string error;
std::shared_ptr<Module> vst_module = Module::create(vst3_module_path, error);
std::vector<ClassInfo> class_infos = vst_module->getFactory().classInfos();;
assert(error.empty());
assert(class_infos.size());
ClassInfo plugin_info = class_infos[0]; //Crash
//... load the plugin and do more things
return 0;
}
Run Code Online (Sandbox Code Playgroud)
其中仅包含来自和
8 的Vst3CommonIncludes.h所有 VST SDK 标头pluginterfaces/vstpublic.sdk/source/vst
就我而言,SDK 包含源文件和 cmake 文件,可将它们构建到静态库中。所以我的代码和SDK代码共享同一个编译器。
我的调查显示PluginFactory::classInfos()返回了损坏的数据,尝试从它们中分配原因,std::bad_alloc因为 的大小std::string无效。
VST SDK中PluginFactory::classInfos()的定义:
PluginFactory::ClassInfos PluginFactory::classInfos () const …Run Code Online (Sandbox Code Playgroud)