Cannot build audiopluginhost on Windows

Will check again, but I’ve def run that in the past

I found issues compiling under MacOS…

I had to add

struct VstEditorBounds
{
int16 upper;
int16 leftmost;
int16 lower;
int16 rightmost;
};

back into juce_VSTPluginFormat.cpp (since the header where it was defined has been removed).

I added it at:

#if JUCE_MAC
   #if JUCE_SUPPORT_CARBON
    
    struct VstEditorBounds
    {
    int16 upper;
    int16 leftmost;
    int16 lower;
    int16 rightmost;
    };
    
    
    struct CarbonWrapperComponent   : public CarbonViewWrapperComponent
    {

I also had to add

 using namespace Vst2;

back in at the top after the

namespace Vst2
{
#include <pluginterfaces/vst2.x/aeffect.h>
#include <pluginterfaces/vst2.x/aeffectx.h>
}

using namespace Vst2;

Rail

I’m finding that the VST hosting isn’t right since this commit… it’s related to the editor size being returned as a width and height of 1 pixel… probably related to your removing the VstEditorBounds struct in the commit… where it still works on MacOS because I added the struct declaration back in.

Rail

Exactly how are you building this? I just tested compiling the plugin host on windows 10 64-bit with VST hosting and it works without any hacks (Ed’s been testing this as well on his machine - and our CI system builds the plugin host with VST hosting on every commit). You shouldn’t need to add any definitions etc.

I tested both just straight opening the host’s VS solution file after a repo pull and re-saving it with the Projucer.

I updated the JUCE modules… and added the vst2.x folders to the SDK in their original location… and built my existing plug-in with no other changes… and hosting works fine on MacOS with the changes above… but on Windows VST2 is broken and VST3 is fine. Debugging shows that the editor reports a size of 1 pixel wide and 1 pixel high.

I don’t use PJ for my project… IJ was used to create it originally, but since then I maintain it manually.

I’ll go ahead and build the host on Windows and test it here.

I had to add the struct back for MacOS to compile.

To clarify, I’m not using the new embedded SDK, but the existing SDK i was using before this commit with the addition of the vst2.x folder.

Rail

Then try creating a project (or the audio demo host) with the Projucer and look at how we changed the header search paths. However, remember to remove the “Custom VST3 Path” as Ed states in his post above.

This is not necessary if the project is saved correctly with the Projucer. Again our CI would moan if this were a problem.

How could that be?? Line 3272…

        bool getEmbeddedViewSize (int& w, int& h) override
        {
            VstEditorBounds* rect = nullptr;
            owner.dispatch (effEditGetRect, 0, 0, &rect, 0);
            w = rect->rightmost - rect->leftmost;
            h = rect->lower - rect->upper;
            return true;
        }

must have complained

if the code’s not excluded because of the barrier macros

#if JUCE_MAC
   #if JUCE_SUPPORT_CARBON
    

Rail

I shouldn’t have to change my VST search paths or locations… I’m still using my external SDK copy with the added vst2.x folder – unless you’re implying there’s more than those headers different in your SDK copy and the Steinberg copy.

My plug-in compiles fine… the only issue is the VST2 editor size being reported wrong.

Rail

OK. Our CI doesn’t build for carbon anymore. I’ve fixed this and it should appear on develop shortly.

You can do this as well with the Projucer by changing the “Custom VST3 SDK” field. I just tried this and it works as expected. Where exactly is a 1 pixel size being returned?

When I create my PluginWindow (DocumentWindow)… when I use

 setContentOwned (pEditor, true);

if I look at the bounds for pEditor… for VST2 in this commit it always returns 1 pixel for width and height… this works fine before the commit.

About to try building the JUCE Host to test on Windows…

Rail

If you look at the commits diff here:

https://github.com/WeAreROLI/JUCE/commit/cf4f12a452611e46d29e4549ce69adac345706b7#diff-e82ff0841200e769a904361ea699b985L2999

(the link takes a long time to load - give github a few seconds and it will jump to the correct line)
then you can see that we are really just doing the following replacements:

plugInOpcodeGetEditorBounds -> Vst2::effEditGetRect
VstEditorBounds -> Vst2::ERect
w = rect->rightmost - rect->leftmost; h = rect->lower - rect->upper; -> w = rect->right - rect->left; h = rect->bottom - rect->top;

I can’t really see anything wrong there. Can you spot anything?

So while the Host works… it does report the wrong size… I have to have the correct size reported because I have a toolbar and change the Window width to make sure things fit…

Note the bounds size is 1 x 1

I’ll examine your changes more closely to see where the issue is.

Rail

Okay… This was brand new code for my plug-in… so I have to verify what the code did in the pre-VST change commit to make sure my report is accurate…

     const double dToolbarWidth = 411.0;

    Rectangle<double> editorRect = pEditor->getBounds().toDouble();
    
    if (editorRect.getWidth() < dToolbarWidth)
        setContentOwned (pEditor, bIsTheGlue || bIsValhalla);  // TheGlue and Valhalla are fully scalable and need to allow the Window to be resized.
    else
        setContentOwned (pEditor, true);

On MacOS and Windows with VST3 editorRect is the correct size before setContentOwned() is called which calls openPluginWindow() where the editor size is checked.

On MacOS editorRect is the correct size before setContentOwned() is called for all plug-in formats (VST2, VST3 and AU).

On Windows for VST2, editorRect shows the editor width and height to be 1 pixel before setContentOwned() is called.

VST3:

I’ll revert my code and let you know if this is new since the VST2 changes to JUCE.

Thanks,

Rail

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.