@Dave Gamble 成功了,但我想在 VST shell 插件上添加一些东西,因为它们使用起来有点棘手。
要确定 VST 是否为 shell 插件,请将effGetPlugCategory 操作码发送到插件调度程序。如果它返回kPlugCategShell,那么它是一个shell 插件。要获取 shell 中的子插件列表,您基本上调用 effShellGetNextPlugin 直到它返回 0。示例代码片段(改编自 working VST host):
// All this stuff should probably be set up far earlier in your code...
// This assumes that you have already opened the plugin and called VSTPluginMain()
typedef VstIntPtr (*Vst2xPluginDispatcherFunc)(AEffect *effect, VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt);
Vst2xPluginDispatcherFunc dispatcher;
AEffect* plugin;
char nameBuffer[40];
while(true) {
memset(nameBuffer, 0, 40);
VstInt32 shellPluginId = dispatcher(pluginHandle, effShellGetNextPlugin, 0, 0, nameBuffer, 0.0f);
if(shellPluginId == 0 || nameBuffer[0] == '\0') {
break;
}
else {
// Do something with the name and ID
}
}
如果你真的想在 VST shell 中加载插件,那就有点棘手了。首先,您的主机需要处理主机回调中的audioMasterCurrentId 操作码。当你调用 VST 的 VSTPluginMain() 方法来实例化插件时,它会用这个操作码调用主机回调并询问应该加载的唯一 ID。
因为此回调是在 主函数返回之前进行的(因此,在它向您的主机传递 AEffect* 之前),这意味着您可能需要将 shell 插件 ID 存储到加载全局变量,因为您将无法及时保存指向 AEffect 结构的 void* user 字段中任何有意义数据的指针,以便在主机回调中将其传回给您。