SysEx markers in VST3 wrapper

Hi there,

I had some issues with SysEx messages in the VST3 wrapper. It happened on Cubase and Reaper with 6.0.3. The wrapper calls MidiMessage::createSysExMessage() which encapsulates the data bytes with the SysEx markers 0xF0 and 0xF7.

It is in modules/juce_audio_processors/format_types/juce_VST3Common.h:

        case Steinberg::Vst::Event::kDataEvent:
            return MidiMessage::createSysExMessage (e.data.bytes, (int) e.data.size);

However it seems that e.data.bytes already contains the SysEx markers yielding a double encapsulation.

I am surprised to be the first one to have this issue. Here is a quick and dirty fix:

        case Steinberg::Vst::Event::kDataEvent:
            if (e.data.size > 3 && e.data.bytes[0] == 0xF0 && e.data.bytes[e.data.size-1] == 0xF7)
            {
                return MidiMessage::createSysExMessage (e.data.bytes+1, (int) e.data.size-2);
            }
            else
            {
                return MidiMessage::createSysExMessage (e.data.bytes, (int) e.data.size);
            }

I am not aware of VST3 specs so there might be a cleaner way, but I don’t want to dig further. That worked for me.