JUCE Assertion failure in juce_VST_Wrapper.cpp:269

Hey Im following the coding the audio plugin tutorial(https://www.juce.com/doc/tutorial_code_basic_plugin) and I have ran into a couple of issues trying to run the example plugin. It was working fine but now when I try and load it in the JUCE plugin host it cant load and I get this error in the console

JUCE Assertion failure in juce_VST_Wrapper.cpp:269

Im on OSX running xcode and I have just updated my JUCE version as well.

Here is the code from the process block function:

void Jucepart2AudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) {
    buffer.clear();

    MidiBuffer processedMidi;
    int time;
    MidiMessage m;

    for (MidiBuffer::Iterator i(midiMessages); i.getNextEvent(m, time);) {
        if (m.isNoteOn()) {
            uint8 newVel = (uint8)noteOnVel;
            m = MidiMessage::noteOn(m.getChannel(), m.getNoteNumber(), newVel);
        }
    
        processedMidi.addEvent(m, time);
    }

    midiMessages.swapWith(processedMidi);
}

I am afraid I can’t give a precise answer because this would require some more specific info on what is going on in your plugin.
Here instead are some hints on how to find that information:

  • If your code fails an assertion it is always a good idea to look at the line above it. The wise JUCE people have put a message here that is meant to explain what went wrong in your code. (In this case the answer can be found in juce_VST_Wrapper.cpp line 268)
  • if the assertion comment does not ring a bell then take a look at the call stack. You can see which of your functions made the call into the JUCE framework that in the end lead to the failed assertion.
  • by now you should have gotten a better understanding of the issue and maybe you can already implement a fix. If not come back here and share the information you have found.
  • Writing the forum post try to be as precise as you can with the description of the problem and its context. You might even find the anwer to your question yourself while you write it down. (that happens a lot to me and this forum has missed quite some traffic because of that.)
1 Like

The code is the exact same as in the tutorial I have linked above. Here is the full console output:

JUCE v5.0.2
Attempting to load VST: /Users/Nicholas/Library/Audio/Plug-Ins/VST/JUCEPart2.vst
JUCE v5.1.1
Creating VST instance: JUCEPart2
JUCE Assertion failure in juce_VST_Wrapper.cpp:269

I dont think any of my code is actually running yet because it seems to run the JUCEApplicationBase::main(int, char const**) method and then there is a bunch of calls to other methods and then it throws an error when it gets to the juce_VST_Wrapper.

I can build the program fine but the error occurs when I actually run it and try and load the plugin in the JUCE plugin host.

If you open up juce_VST_Wrapper.cpp and scroll down to line 269 you’ll see this:

    // You must at least have some channels
    jassert (processor->isMidiEffect() || (maxNumInChannels > 0 || maxNumOutChannels > 0));

The assertion failure is telling you are trying to instantiate the plugin with no input/output channels.

Ok that makes a little more sense but first you have to load the plugin into the JUCE plugin host then you can add the audio input and output channels and also the midi ones. I’m basically trying to test the program and I can only do it in the JUCE host because I wont be able to do it with ableton(because it doesnt recognise the VST plugin as a midi effect which this basically is)

Then you probably forgot to set something because this processor->isMidiEffect() should then return true (which it doesn’t and this is why Live can’t load it, because it triggers that assertion).

Ok I’ve had a bit of a read of the file thats throwing the error and yes isMidiEffect() should be returning true but its not in this case. I have just double checked that I ticked is midi effect in the setting in Projucer and I have also ticked plugin wants Midi input.

I also looked at the code in the AudioProcessor class and it has some preprocessor conditionals with some macros so maybe the macros havent been updated? The projucer has no save in the settings so I’m just exiting out. Is this saving the changes?

It should, yes.

Projucer doesn’t save the settings automatically. You have to click on File > Save, or press Ctrl+S.

Yeah I’ve double checked it was already saved and its still not running. Even when I scan for new VSTs in the JUCE plugin host is crashes at the same point. Everything is building successfully. Is there anyway I can see the macros and see if it actually has saved properly?

Check how the function is computed and see if everything is set up properly.

I actually have no clue what is going on now aha. The plugin seems to open fine in ableton and there is a vertical scroll bar that works and everything but ableton only recognises it as an audio plugin not a midi one (Midi effects go before the instrument and audio after).

Just realised, that the default boilerplate does not override isMidiEffect() (I kinda remember, it used to do so)

Your plugin lacks the override, just add

bool isMidiEffect () const override {
#ifdef JucePlugin_IsMidiEffect
    return true;
#else
    return false;
#endif
}

@ed95 / @t0m: was that intentional? If so, you might remove the Projucer option for that define as well…

HTH

1 Like

Ayy that fixed! Thanks for that. Yeah I was looking at the overrided methods and only saw that accepts midi and produces midi where overridden but didnt think much of it.

I’ve added this to the new plug-in template code.

It seems to me that this issue sitll exists:

The assertion on line 273 in juce_VST_Wrapper.cpp:

jassert (processor->isMidiEffect() || (maxNumInChannels > 0 || maxNumOutChannels > 0));

is still failing.

I used the latest Projucer (v. 5.2.3) to created Audio-Plugin project for VS2017 (on Windows 7).
In the resulting project, the lines 351-352 in AppConfig.h read:

>     #ifndef  JucePlugin_IsMidiEffect
>      #define JucePlugin_IsMidiEffect           1

yet, lines 838-839 in juce_AudioProcessor.h still read:

/** Returns true if this is a MIDI effect plug-in and does no audio processing. */
	virtual bool isMidiEffect() const { return false ; }

When I change the return value of sMidiEffect() to “true”, it seems to work fine.

NOTE: I checked the “Plugin MIDI Input”, “Plugin MIDI Output” and “Midi Effect Plugin” options in the Project Setting section of Projucer.

Am I missing something about how Projucer generates projects?

Please advise.

The line you posted is fro the AudioProcessor base class - the plug-in template derives from this and returns a value based on whether the “MIDI Effect Plugin” flag is set, see here.

Perhaps check the other conditions of the assertion, whether maxNumInChannels is > 0 or maxNumOutChannels is > 0.

Thanks for your response.
My whole point is that the plug-in template - demonstrably - doesn’t return ‘true’ when “MIDI Effect Plugin” flag in “Project Settings” section of Projucer is set.

I can see that

processor->isMidiEffect();

is expected to return “true” if this:

bool isMidiEffect () const override {
#ifdef JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}

worked as expected, but it doesn’t. Given that, my question becomes:
What’s the point of setting the “MIDI Effect Plugin” flag in Projucer if one still needs to fiddle around with the code anyway?

Also, why would I need to “check the other conditions of”

jassert (processor->isMidiEffect() || (maxNumInChannels > 0 || maxNumOutChannels > 0));

when Projucer generates the following code? [emphasis mine]

void processBlock (AudioBuffer& buffer, MidiBuffer& midi) override
{
// the audio buffer in a midi effect will have zero channels!
jassert (buffer.getNumChannels() == 0);

How are you demonstrating this, exactly? I’ve taken the latest Projucer from the JUCE website download (v5.3.2) and created a new Audio Plug-in template project, then I have set the MIDI Effect Plugin option in the Plugin Characteristics group of the project settings. I’ve saved and opened the project in Xcode and added the following lines to my AudioProcessor's constructor in PluginProcessor.cpp:

if (isMidiEffect())
    DBG ("true");

It prints true to the console.

I replicated project creation routine with Projucer 5.3.2 just like you did and, in fact it is working as expected.
I don’t recall exact steps I took that resulted in that “asserting” code, but the assertions did fail as I described earlier. Anyway; it works now, so never mind the whole thing.
Sorry for the hassle :slight_smile: