Hosting Steinberg plugins

Hi,

I’m working on a plugin that hosts other plugins (only one at a time). It works for most plugins, but crashes when I try to load Steinberg plugins (like HALion Sonic or The Grand).

The crash happens in juce_VST3PluginFormat.cpp at this line:

processor->process (data);

I’m using the latest version of JUCE 8. Here’s the relevant code in my processBlock function:

ScopedNoDenormals noDenormals;
const ScopedTryLock tryLock(innerMutex);

for (auto i = getTotalNumInputChannels(); i < getTotalNumOutputChannels(); ++i)
    buffer.clear(i, 0, buffer.getNumSamples());

if (tryLock.isLocked())
{
    if (inner != nullptr)
    {
        inner->setPlayHead(getPlayHead());
        inner->processBlock(buffer, midiMessages);
    }
}

The issue only occurs when loading Steinberg plugins. The same plugins work fine in other hosts like REAPER. Has anyone encountered a similar issue or have suggestions on how to resolve it?

Thanks!

maybe the issue is because you run it under a debugger ?

Thanks for the suggestion! I’ve tested the plugin both with and without the debugger, and the crash occurs in both scenarios. Specifically, the crash happens when calling inner->processBlock(buffer, midiMessages) in my plugin’s processBlock function, and this is consistent regardless of whether I’m running under a debugger.

I’ve confirmed that the crash is specific to Steinberg plugins like HALion Sonic and The Grand. Other VST3 plugins process audio correctly in my host plugin without any issues. Additionally, Steinberg plugins work as expected in other hosts like REAPER and JUCE’s AudioPluginHost, which leads me to believe the issue might be related to how my host plugin interacts with Steinberg plugins during the processing phase.

Let me know if there’s anything else I could try or specific debugging steps you’d recommend to narrow this down further. Thanks!

If it works in juce Audio PLuginHost, I suspect your issue lies in the number and size of your audio buffer that you pass to the plugin

Thanks for your suggestion! After further investigation, I discovered that the issue was related to the handling of the audio buffer in my host plugin. Specifically, I wasn’t correctly matching the number of channels in the buffer with the requirements of the hosted plugin. This mismatch caused Steinberg plugins like HALion Sonic and The Grand to crash during processing.

To fix this, I removed the following line from my initialization function:

inner->setPlayConfigDetails(jmin(inner->getTotalNumInputChannels(), getTotalNumInputChannels()), 
                            jmin(inner->getTotalNumOutputChannels(), getTotalNumOutputChannels()), 
                            getSampleRate(), getBlockSize());

And I added this to my processBlock() function

AudioBuffer<Type> innerBuffer(jmax(inner->getTotalNumInputChannels(), inner->getTotalNumOutputChannels()), buffer.getNumSamples());

for (int i = 0; i < innerBuffer.getNumChannels(); ++i)
{
    if (i < buffer.getNumChannels())
        innerBuffer.copyFrom(i, 0, buffer.getReadPointer(i), buffer.getNumSamples());
    else
        innerBuffer.clear(i, 0, buffer.getNumSamples());
}

inner->setPlayHead(getPlayHead());
inner->processBlock(innerBuffer, midiMessages);

for (int i = 0; i < innerBuffer.getNumChannels(); ++i)
{
    if (i < buffer.getNumChannels())
        buffer.copyFrom(i, 0, innerBuffer.getReadPointer(i), buffer.getNumSamples());
}

This ensures that the AudioBuffer passed to the hosted plugin has the correct number of channels, matching the plugin’s getTotalNumOutputChannels().

With this change, Steinberg plugins now load and process audio correctly in my host plugin. It appears that the mismatch in the buffer configuration was the root cause of the crash.

Thanks again for pointing me in the right direction—it helped narrow down the problem!