Skip to content

Sending arbitrary length MIDI messages #19

Open
@vockleya

Description

@vockleya

I'm working on a project that requires me to send a different length of MIDI message than the standard 4-byte note on/off, and program/control change messages. It seems like this should be trivial, but I'm having trouble getting it to work. It looks like I should be able to use the MidiUSB.write() function to send arbitrary data to the computer, but I'm getting very odd messages on the computer.

Here's the snippet of code that is actually sending the data.

uint8_t data[7] = {0xF0, 0x7F, 0x00, 0x02, 0x7F, 0x01, 0xF7};
MidiUSB.write(data, 7);
MidiUSB.flush();

I'm using Snoize MIDI Monitor on OS X 10.11.5 to view the messages. Depending on the content of the message, I get anywhere from nothing, to a single byte, to something random that wasn't even in the original message. Given the example above, MIDI Monitor shows a message 1 byte long, with the contents of whatever is in the second to last byte, and in this case 0x01.

The message I'm trying to send is a SysEx MIDI show control "go" command (and various others once I get this working). According to the SysEx/MSC spec, I'm using the correct byte sequence.

As far as I can tell, all the sendMIDI() function does is create a data buffer from the midiEventPacket_t passed to it, and then calls write(). I'm just creating my own buffer and directly calling write(). It's interesting to note that when I use a standard 4-byte note on message in my code above, it works correctly.

Edit: After a bit more playing around, I've discovered some even weirder behavior. The bit of code above is run by a button press. There's no issue with the button push detection/debouncing code. If I comment out the MIDIUSB.flush() line, and spam push the button, sometimes the complete message makes it through, and sometimes it's garbled, truncated, or otherwise messed up as before. So I know the data is getting to the computer properly, but it seems like it's being misinterpreted by the computer. Am I just running into a limitation of the library, or is there something I'm missing?

Additional context

Additional requests

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: enhancementProposed improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions