MIDI Library Unexpected SysEx Behavior

Hello-

I’m seeing some unexpected behavior when using the MIDI library to parse a particular string of System Exclusive.

Nearly all SysEx that I send works as expected, except for a patch dump from a Sequential Prophet VS synthesizer.

Here is my test code running on a Adafruit ItsyBitsy:

#include <MIDI.h>

MIDI_CREATE_DEFAULT_INSTANCE();

// -----------------------------------------------------------------------------

// This example shows the old way of checking for input messages.
// It's simpler to use the callbacks now, check out the dedicated example.

#define LED 13                   // LED pin on Arduino Uno

// -----------------------------------------------------------------------------

void BlinkLed(byte num)         // Basic blink function
{
    for (byte i=0;i<num;i++)
    {
        digitalWrite(LED,HIGH);
        delay(50);
        digitalWrite(LED,LOW);
        delay(50);
    }
}

// -----------------------------------------------------------------------------

void setup()
{
    pinMode(LED, OUTPUT);
    MIDI.begin();           // Launch MIDI, by default listening to channel 1.
}

void loop()
{
    if (MIDI.read())                // Is there a MIDI message incoming ?
    {
        switch(MIDI.getType())      // Get the type of the message we caught
        {
            case midi::SystemExclusive:       // If it is SysEx,
                BlinkLed(5);                // blink the LED 5 times
                break;
            // See the online reference for other message types
            default:
                break;
        }
    }

If the microcontroller recognizes incoming SysEx data, it blinks the LED 5 times.

This works as expected for a variety of synthesizers.

Here is the SysEx string that breaks it:

00  F0 01 0A 00 09 07 02 0E  05 0C 0B 00 00 00 00 00  |                |
10  00 00 02 0C 01 09 01 04  0E 00 00 0C 08 01 01 02  |                |
20  01 01 00 02 00 06 0A 00  05 09 00 01 08 0E 0A 0D  |                |
30  00 00 01 05 0B 0C 06 0B  05 06 04 0B 02 0C 06 0D  |                |
40  01 06 00 00 00 00 05 0A  04 05 04 05 05 0C 08 00  |                |
50  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |                |
60  00 00 0F 06 0A 08 00 00  00 00 00 02 0E 08 0E 0F  |                |
70  0C 02 00 09 0F 0B 0D 0F  0D 07 0E 01 09 0C 0E 0A  |                |
80  0E 01 00 01 07 0F 0D 07  0C 00 02 00 00 0C 00 0E  |                |
90  02 00 02 04 04 04 06 04  00 00 00 03 00 03 00 01  |                |
A0  04 00 02 06 04 06 00 00  F7

To decode the first few bytes:

F0 - Start of SysEx
01 - Manufacturer’s ID, Sequential/DSI
0A - Specific device, Prophet VS
00…00 - Data
F7 - End of SysEx

I’m stumped.

Is there something in the MIDI Library configuration file that needs adjusting? Is the library unhappy with the 0A device ID?

Any input would be appreciated. Thanks!

What's the behavior you're seeing and how does that differ from what you expect?

How are you sending the MIDI message?

Pieter

The SysEx from the Prophet does not blink the LED.

I am sending the message directly from the synthesizer, and have also sent it using the application SysEx Librarian on my computer.

Neither method causes the LED to blink.

When I send a different SysEx message directly from the synthesizer (waveform dump), the LED blinks as expected.

I'm unable to reproduce this issue using an Arduino Leonardo (32U4 like the ItsyBitsy) and version 5.0.2 of the MIDI library. The LED blinks 5 times like it should.

I think the problem is that the sysEx data can only be four bytes long. Also the message is so long that it fills up the buffer before it even gets to decode it. Hence it never sees the end of message so it doesn’t recognise that it has received a sysEx message in the first place. Do some searching there are examples on line of how to get round this.

frankie47 was able to solve this problem on the MIDI Library forum in this discussion.

I solved the problem by changing the size of the default setting for the SysEx size to 256 bytes.

Thank you all for your input.

PieterP - I suspect that your default SysEx size was larger than mine, and that was why you had success. Thanks for taking the time to investigate this!

randel:
PieterP - I suspect that your default SysEx size was larger than mine, and that was why you had success. Thanks for taking the time to investigate this!

I’ve just removed and reinstalled my copy of the MIDI library. I’m using the 5.0.2 release on GitHub (also tried the boards manager version 5.0.2). It works correctly for me, without changing any buffer sizes.
I also tried the fix proposed in the GitHub discussion. This only seems to work on the latest master version. Even when I set the buffer size to 1, the LED still blinks whenever I send your SysEx message. Here’s the exact code I used:

#include <MIDI.h>


struct MySettings : public midi::DefaultSettings {
  static const unsigned SysExMaxSize = 1;
};


// Create a 'MIDI' object using MySettings bound to Serial1.
MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, MIDI, MySettings);
#define LED 13                   // LED pin on Arduino Uno
// -----------------------------------------------------------------------------
void BlinkLed(byte num) {         // Basic blink function
  for (byte i = 0; i < num; i++) {
    digitalWrite(LED, HIGH);
    delay(50);
    digitalWrite(LED, LOW);
    delay(50);
  }
}
// -----------------------------------------------------------------------------
void setup() {
  pinMode(LED, OUTPUT);
  MIDI.begin();           // Launch MIDI, by default listening to channel 1.
  Serial1.begin(115200);
}
void loop() {
  if (MIDI.read()) {              // Is there a MIDI message incoming ?
    switch (MIDI.getType()) {     // Get the type of the message we caught
      case midi::SystemExclusive:       // If it is SysEx,
        BlinkLed(5);                // blink the LED 5 times
        break;
      // See the online reference for other message types
      default:
        break;
    }
  }
}

It probably won’t be able to store all SysEx data it received, but it still detects that a SysEx message was received.
If it works now, that’s great, but in case you notice other problems, it’s probably good to keep in mind that maybe some other factor caused the issues you were seeing.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.