Sending SysEx MIDI messages

869 views
Skip to first unread message

Dan Kersten

unread,
Jun 20, 2011, 7:35:41 AM6/20/11
to LUFA Library Support List
Hi,

I am trying to send and receive MIDI SysEx messages and I can receive
them fine, but I am having trouble sending.

Basically, I'm not really sure how to go about sending them. I tried
passing a byte buffer for LUFA to send, but that did not work (I did
not receive anything on the other end). I tried splitting the message
in the same way that the input messages are split when they arrive
(eg, 1, 2 or 3 byte packets + command byte), but that didn't work for
me either.

Any tips, help or pointers to documentation would be greatly
appreciated!

Thanks,
Dan.

Robin Green

unread,
Jun 20, 2011, 8:36:05 AM6/20/11
to lufa-s...@googlegroups.com
USB-MIDI is a little different than straight MIDI. You need to package
your MIDI stream into 4-byte packets for transmission over USB. As
most MIDI messages are 3 bytes you simply add a header byte that tells
the USB system which "virtual device" this MIDI is coming from but as
SYSEX messages are a variable number of bytes you need to use the 1-,
2- and 3-byte message packets to assemble a stream of USB packets from
your SYSEX stream. Table 4.1 in the MIDI-USB standard shows you the
list of available packets:

http://www.usb.org/developers/devclass_docs/midi10.pdf

Packets 4,5,6 and 7 are the ones you need. Examples of SYSEX are on table 4.2.

In fact, read the whole document. It explains a lot about the
paramaters that LUFA uses to construct USB packets and also points out
the large implementation holes in the sender and parser that I haven't
gotten around to filling yet with code yet...

- Robin Green.

> --
> You received this message because you are subscribed to the Google Groups "LUFA Library Support List" group.
> To post to this group, send email to lufa-s...@googlegroups.com.
> To unsubscribe from this group, send email to lufa-support...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/lufa-support?hl=en.
>
>

Dan Kersten

unread,
Jun 20, 2011, 1:39:50 PM6/20/11
to LUFA Library Support List
Hi Robin,

Perfect! Thanks, that explains it alright. I didn't realize that USB-
MIDI was handled a little differently.

Thanks for the help.
Dan.

Xulio Coira

unread,
Aug 9, 2012, 11:09:32 PM8/9/12
to lufa-s...@googlegroups.com
Hi Dan,

Here is some code I wrote in order to send SYSEX messages with LUFA, in case you find it useful.


BR,

Xulio.

Robin Green

unread,
Aug 9, 2012, 11:46:37 PM8/9/12
to lufa-s...@googlegroups.com

Beautiful code, man. Really clear.

- Robin Green

To view this discussion on the web visit https://groups.google.com/d/msg/lufa-support/-/in1oGPPqapAJ.

Donald Delmar Davis

unread,
Aug 9, 2012, 11:51:10 PM8/9/12
to lufa-s...@googlegroups.com
now on to the sysex bootloader.....

Dean Camera

unread,
Aug 11, 2012, 8:53:35 AM8/11/12
to lufa-s...@googlegroups.com
Xulio, well done, that's damned near poetry in code - as Robin says, very clean.

I remember discussing making a MIDI class bootloader with Feurig a while back and even started an implementation, but gave up when I couldn't figure out the best way to make a host-side application to drive it. Perhaps I should look into that again.

- Dean

Xulio Coira

unread,
Aug 11, 2012, 11:06:44 AM8/11/12
to lufa-s...@googlegroups.com
Hi Dean,

I've also in my mind a MIDI firmware update procedure, using SYSEX, but not using MIDI class bootloader.
I would send firmware image using SYSEX, save to flash, and then the DFU bootloader detect and flash it, but it's only in my mind by now :)

Sorry for my ignorance, but why a MIDI class bottloader could be useful?

Regards,

Xulio.

Donald Delmar Davis

unread,
Aug 12, 2012, 1:56:08 PM8/12/12
to lufa-s...@googlegroups.com
Midi is setup up for in band software updates (really one of the bigger reasons for sysex). 
You can upload and run new code without ever leaving the class.   The client side is really kind of the painful part. 
I wrote a protocol a few years back called (lets get loaded) and started a python based loader for it. 
I will see if enough of it is fleshed out to make a spec. 



To view this discussion on the web visit https://groups.google.com/d/msg/lufa-support/-/klA4zUFUAXYJ.

Dean Camera

unread,
Aug 13, 2012, 2:04:46 PM8/13/12
to lufa-s...@googlegroups.com
It's also driver-less on many systems - I've been wondering if it would be possible to encode firmware into an actual MIDI file, and then play that to the device to download new code. That would allow for software-less upgrades on the client side. If nothing else, it's another option people can choose if they wish.

Donald: if you can cook up a front-end for it, I can make the bootloader if you don't want to do it.

- Dean

Sebastian Steppeler

unread,
Aug 13, 2012, 3:17:26 PM8/13/12
to lufa-s...@googlegroups.com
This would be perfectly possible! You'd just use e.g. note on messages and encode a nibble in the note number and the other one in the velocity. You could then always create note on and note off blocks to obey the midi protocol - just to be sure nothing weird happens.
Of course you could also use sysex messages, but I don't know if every player will pass them on unchanged...

regards,
Sebastian

2012/8/13 Dean Camera <abcmi...@gmail.com>
To view this discussion on the web visit https://groups.google.com/d/msg/lufa-support/-/vrtIKZe0xM8J.
Reply all
Reply to author
Forward
0 new messages