Some info re: sending out MIDI system exclusive messages from a VST3

I just wanted to share an issue I encountered with the way Juce adds MIDI system exclusive messages to the VST3 wrapper’s outgoing event list. I wouldn’t say it’s a bug, but it is something you should be aware of if you want to output SysEx messages from your plugin.
The relevant code for this resides in juce_VST3Common.h lines 560 to 566:

else if (msg.isSysEx())
{
    e.type          = Steinberg::Vst::Event::kDataEvent;
    e.data.bytes    = midiEventData + 1;
    e.data.size     = (uint32) msg.getSysExDataSize();
    e.data.type     = Steinberg::Vst::DataEvent::kMidiSysEx;
}

Notice that in this code the “begin SysEx” byte (xF0) and the “end SysEx” byte (xF7) are not included in the event that gets sent out. I think that there is an expectation that the plugin’s host program will add back the wrapper bytes when the event gets handed off to it. Unfortunately, not all hosts do this.

As an experiment, I created a simple VST3 that requests a data dump from a hardware synthesizer via a system exclusive message. When I run the plugin in Juce’s AudioPluginHost, it appears that the xF0/xF7 bytes get added back to the request message, the synthesizer recognizes it, and it responds with the data dump. When I run the plugin in Reaper, however, the wrapper bytes do not get added and the synthesizer does not recognize the request message.

I then modified the Juce code so that the wrapper bytes are included in the event:

else if (msg.isSysEx())
{
    e.type          = Steinberg::Vst::Event::kDataEvent;
    e.data.bytes    = midiEventData;
    e.data.size     = (uint32) msg.getRawDataSize();
    e.data.type     = Steinberg::Vst::DataEvent::kMidiSysEx;
}

The request message now comes out as properly-formed SysEx in Reaper, the synthesizer recognizes it, and it responds with the data dump. In AudioPluginHost, I think the message winds up looking like xF0 xF0 [message bytes] xF7 xF7, but the synthesizer still recognizes the request message and responds appropriately. I think in the vast majority of cases the duplicate SysEx wrapper bytes will just be ignored by the target device, but there may be some devices out there that will get confused, so use this with caution.

1 Like

I’ve done further experimentation with this and have determined that a SysEx message with the form F0 F0 [message bytes] F7 F7 will not be recognized by the target device. The second F0 is not considered the start of a new SysEx message, it is interpreted as the first byte of the message having the value F0. This will make whatever message you’re trying to send invalid. I also tried putting an F7 byte at the start of the SysEx message so it would have the form F0 F7 F0 [message bytes] F7 F7. Unfortunately, when the host hits the first F7 byte, it simply ignores the subsequent bytes in the message and the resulting output is F0 F7. What this all boils down to is that it is necessary to compile a separate version of the plugin that strips off the wrapper bytes in order for it to function properly in hosts that add the wrapper bytes back on.