Using ExternalPlugin::setBusesLayout


I’m trying to change the bus layout of a te::ExternalPlugin (a VST3 plugin) that is in a Rack.
Calling te::ExternalPlugin::setBusesLayout(layout) will trigger an assertion with the following comment:

// someone tried to change the layout while the AudioProcessor is running
// call releaseResources first!

Relevant part of the call stack:

juce::VST3PluginInstance::canApplyBusesLayout(const juce::AudioProcessor::BusesLayout & layouts) 
juce::AudioProcessor::setBusesLayout(const juce::AudioProcessor::BusesLayout & arr) 
tracktion_engine::ExternalPlugin::setBusesLayout(juce::AudioProcessor::BusesLayout layout) 

None of the te::ExternalPlugin (or te::Plugin) code seems to call releaseResources on the wrapped AudioProcessor so I’m not sure how this is supposed to work. (A comment in ExternalPlugin::initialise does mention a reason for not calling releaseResources but I’m not sure if this is relevant since this function is not called when trying to change the bus layout).

Is this the correct way to use te::ExternalPlugin::setBusesLayout?

(I’m using tracktion_engine at bf2bf46e1 which is not the latest but the functions mentioned above seem to be the same on the current master as well)

I think in ExternalPlugin::setBusesLayout, the following lines used to release resources:

        std::unique_ptr<Edit::ScopedRenderStatus> srs;

        if (! baseClassNeedsInitialising())
            srs = std::make_unique<Edit::ScopedRenderStatus> (edit, true);

        jassert (baseClassNeedsInitialising());

But if I look in ExternalPlugin::initialise there’s this comment:

        // This used to releaseResources() before calling prepareToPlay().
        // However, with VST3, releaseResources() shuts down the MIDI
        // input buses and then there is no way to get them back, which
        // breaks all synths.

So it looks like calls to releaseResources were removed.
It looks like we can’t have both mutable busses and MIDI inputs unless this is a JUCE bug that has since been fixed?

Ok, I’ve had a chance to look in to this now and it should be fixed here: Plugins: Fixed a problem setting ExternalPlugin bus configurations … · Tracktion/tracktion_engine@1a4a061 · GitHub