Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receivng Sysex and Sysex Raw MIDI messages in MIDIUSB #48

Open
kaspencer opened this issue Nov 6, 2018 · 5 comments
Open

Receivng Sysex and Sysex Raw MIDI messages in MIDIUSB #48

kaspencer opened this issue Nov 6, 2018 · 5 comments

Comments

@kaspencer
Copy link

uController=Arduino Due
LIbrary=MIDIUSB
I wish to receive Sysex and Sysex Raw MIDI messages using a Due. However I suspect that this is not possible as the read() function seems only to expect a structure of very few data bytes.
Can you confirm the MIDIUSB does indeed not support Sysex message reading?
Can you possibly indicate by which library how this may be done using an Arduino Due?
I am grateful for your work developing the library, and also will be for your help with this issue.
KASpencer

@franky47
Copy link
Contributor

franky47 commented Nov 6, 2018

The USB MIDI specification splits SysEx messages into packets, this library should allow to receive such split data, but you'd need a way to recompose the message. I have a pre-release of the Arduino MIDI library doing this work and interface this MIDIUSB library with your sketch. Check out the discussion in #21 (comment) .

@gdsports
Copy link

gdsports commented Nov 6, 2018

You can compose the 4 bytes raw USB MIDI packets into complete sysex messages.

  // init sysex buffer empty
  midiEventPacket_t rx = MidiUSB.read();
  if (rx.header != 0) {
    switch (rx.header & 0x0F) {
      case 0x00:  // Misc. Reserved for future extensions.
        break;
      case 0x01:  // Cable events. Reserved for future expansion.
        break;
      case 0x02:  // Two-byte System Common messages
      case 0x0C:  // Program Change
      case 0x0D:  // Channel Pressure
        // do something with 2 byte messages
        break;
      case 0x03:  // Three-byte System Common messages
      case 0x08:  // Note-off
      case 0x09:  // Note-on
      case 0x0A:  // Poly-KeyPress
      case 0x0B:  // Control Change
      case 0x0E:  // PitchBend Change
        // do something with 3 byte messages
        break;
      case 0x04:  // SysEx starts or continues
        // append sysex buffer with 3 bytes
        break;
      case 0x05:  // Single-byte System Common Message or SysEx ends with the following single byte
        // append sysex buffer with 1 byte
        // process completed sysex buffer
        // init sysex buffer empty
        break;
      case 0x06:  // SysEx ends with the following two bytes
        // append sysex buffer with 2 bytes
        // process completed sysex buffer
        // init sysex buffer empty
        break;
      case 0x07:  // SysEx ends with the following three bytes
        // append sysex buffer with 3 bytes
        // process completed sysex buffer
        // init sysex buffer empty
        break;
      case 0x0F:  // Single Byte, TuneRequest, Clock, Start, Continue, Stop, etc.
        // process since byte messages
        break;
    }
  }

@kaspencer
Copy link
Author

Thankyou Franky and gdsports for those helpful replies.
I will get on with testing those ideas ASAP. I will report back as seems necessary, but I hope that's enough for me to get on with the project.
Best wishes,
Kenneth Spencer

@lathoub
Copy link

lathoub commented Oct 4, 2020

This issue is resolved in https://github.com/lathoub/Arduino-USBMIDI (fully supporting receiving and sending SysEx) that uses the underlaying FortySevenEffects Arduino MIDI Library (USB-MIDI is one of the transport mechanisms ).

@kaspencer
Copy link
Author

lathoub: thanks for that. I'm glad to say that the project was completed successfully this year, and made use of the librares which you mentioned.
Best wishes,
Kenneth Spencer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants