Cannot add Midi Controller event to MidiBuffer

So… I can use the MidiMessage class to add Note Events to a MidiBuffer but when I try to add a Controller Event, the host (Reaper in my test case) does not receive any Controller events. I can’t see that I’m doing anything wrong. Can anyone confirm this works for them or tell me what I’m doing wrong?

JUCE 5.4.7
Windows 10
Reaper 6.2.9

void MidiFxTestAudioProcessor::processBlock(AudioBuffer<float>& buffer, MidiBuffer& midiMessages)
{
    buffer.clear();

    // this works
    {
        auto msg = MidiMessage::noteOn(1, 60, uint8(100));
        midiMessages.addEvent(msg, 0);
    }

    // this does not work
    {
        auto msg = MidiMessage::controllerEvent(1, 1, 100);
        midiMessages.addEvent(msg, 0);
    }
}

Interestingly enough, the Buffer seems to think it has the controller event, but it does not come through to my host.

For example, if I add the following code, I will trigger the break point:

        int offset = {};
        for (MidiBuffer::Iterator it(midiMessages); it.getNextEvent(msg, offset);)
        {
            if (msg.isControllerOfType(1))
            {
                jassertfalse;
            }
        }

Note that this version of JUCE didn’t include support for outgoing CC events in the VST3 format. You’ll need at least JUCE 6, but I’d recommend updating to the latest version of JUCE. Even then, not all host programs support CC events in VST3 format - I think REAPER does, but I wouldn’t expect this to work in all hosts.

1 Like

@reuk: Ah, that is helpful information! I realized that merely setting the config is enough to kill the live input of MIDI controllers so that they never reach the host, regardless of whether I try to add to the buffer or transform the incoming CCs.

Example:

#ifndef  JucePlugin_WantsMidiInput
 #define JucePlugin_WantsMidiInput         1
#endif
#ifndef  JucePlugin_ProducesMidiOutput
 #define JucePlugin_ProducesMidiOutput     1
#endif

I will update my JUCE and see if it works, at least in Reaper. Hopefully Cubase as well.

Unfortunately, despite upgrading to JUCE v7 and recompiling everything, I still have the exact same problem. As soon as I insert any JUCE plugin configured for MIDI I/O onto the “Input FX” bus in Reaper, all MIDI controller data incoming from my MIDI keyboard is filtered out. As before, I can add Note Events to the midiMessages object that show up in the host, but any Controller events added do not show up.

Since these are actually two separate problems, I am going to create another post specific to the I/O problem.