Cannot build audiopluginhost on Windows

Okay… Looks like I was wrong… and the VST2 even before the VST changes didn’t get the editor size… so we have…

    VSTPluginWindow (VSTPluginInstance& plug)
        : AudioProcessorEditor (&plug),
         #if ! JUCE_MAC
          ComponentMovementWatcher (this),
         #endif
          plugin (plug)
    {
       #if JUCE_LINUX
        pluginWindow = None;
        display = XWindowSystem::getInstance()->displayRef();

       #elif JUCE_MAC
        ignoreUnused (recursiveResize, pluginRefusesToResize, alreadyInside);

        #if JUCE_SUPPORT_CARBON
        if (! plug.usesCocoaNSView)
        {
            carbonWrapper.reset (new CarbonWrapperComponent (*this));
            addAndMakeVisible (carbonWrapper.get());
        }
        else
        #endif
        {
            cocoaWrapper.reset (new AutoResizingNSViewComponentWithParent());
            addAndMakeVisible (cocoaWrapper.get());
        }
       #endif

        activeVSTWindows.add (this);

        setSize (1, 1);
        setOpaque (true);
        setVisible (true);
    }

where the initial editor size is set to 1 x 1… and on MacOS in juce_VSTPluginFormat.cpp it calls openPluginWindow() where the window size is determined… but on Windows there’s no visibilityChanged() method so the editor size remains at 1 x 1

   #if JUCE_MAC
    void visibilityChanged() override
    {
        if (cocoaWrapper != nullptr)
        {
            if (isVisible())
                openPluginWindow ((NSView*) cocoaWrapper->getView());
            else
                closePluginWindow();
        }
    }

    void childBoundsChanged (Component*) override
    {
        if (cocoaWrapper != nullptr)
        {
            auto w = cocoaWrapper->getWidth();
            auto h = cocoaWrapper->getHeight();

            if (w != getWidth() || h != getHeight())
                setSize (w, h);
        }
    }
   #endif

Do you think this should be changed in the wrapper – or should I figure out the Editor size myself?

Cheers,

Rail

Okay, here’s my recommendation:

In juce_AudioProcessorEditor.h

Add a new method:

    /** Returns the bounds of the plug-in's editor Component
     */
    
    virtual Rectangle<int> getEditorSize() noexcept;

with a default implementation:

Rectangle<int> AudioProcessorEditor::getEditorSize() noexcept
{
    return getBounds();
}

VST3 and AU can use the default… but for VST2…

In juce_VSTPluginFormat.cpp add:

    //==============================================================================
    
    Rectangle<int> getEditorSize() noexcept override
    {
        Vst2::ERect* rect = nullptr;
        dispatch (Vst2::effEditGetRect, 0, 0, &rect, 0);
    
        return { rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top };
    }
    
    
#if JUCE_MAC
    void openPluginWindow (void* parentWindow)
    {

I’d then rewrite openPluginWindow() to use getEditorSize()

I can then change my code to reliably check the editor size:

    const int iToolbarWidth = 411;
    
    Rectangle<int> editorRect = pEditor->getEditorSize();
    
    if (editorRect.getWidth() < iToolbarWidth)
        setContentOwned (pEditor, bIsTheGlue || bIsValhalla);
    else
        setContentOwned (pEditor, true);

Cheers,

Rail

I’m going to bump this in the chance y’all would consider adding this method,

Cheers,

Rail

The new commits for Windows scaling have changed the behavior for VST3 plug-ins so now the bounds aren’t returned correctly until much later… if you can please remove the JUCE_MAC guard check around line 1122 in juce_VST3PluginFormat.cpp then we get equity between both platforms.

(I’d still need the above addition for VST2).

Thanks,

Rail

1 Like

@ed95

Hi, I just saw you did a commit which kinda is related to this… and I haven’t received a reply (either in favour or against)… so…

https://github.com/WeAreROLI/JUCE/commit/59e70ad82cab90387218b4e848fa6a4353dbd070

Thanks,

Rail

Hey @Rail_Jon_Rogut - sorry for the delay, this post slipped under the radar somehow.

Removing the #if JUCE_MAC guard in the VST3 hosting code seems sensible and it’d be good to get parity between platforms. As for your suggested change for the VST2 hosting classes however, I’m hesitant to add another method to AudioProcessorEditor's interface, especially one which is only really implemented for one specific case. Instead, adding this to the end of the VSTPluginWindow constructor:

Vst2::ERect* rect = nullptr;
dispatch (Vst2::effEditGetRect, 0, 0, &rect, 0);
setSize (rect->right - rect->left, rect->bottom - rect->top);

setOpaque (true);
setVisible (true);

does the same thing and ensures that calling getBounds() will return the correct size before setContentOwned() is called. However, my concern is that the setSize (1, 1); call is there for a reason and this change could break things - I’ve tested with a few plug-ins in the AudioPluginHost and it seems to work OK but I can’t be 100% sure.

In any case I’d like to give both of these changes a long test before they go onto the master branch as there could be some tricky edge cases that we haven’t anticipated. We’ve got a release coming up fairly soon so it’ll have to wait until after that before I put these changes on the develop branch.