MIDI DESIGNER
The only MIDI controller for iPad, iPhone, and Mac


Talk to other MIDI Designer users about MIDI Designer, iOS MIDI and related topics. Or share layouts, pages, and ideas.

Check out our Facebook Group.

Of course, if you want to send us an email, feel free.

Open problem reports

Summary of user requests
Extra bytes appear in the USB stream - is this normal for MIDI over USB? - MIDI Designer Q&A
0 votes
in Advanced by stevengchristensen (280 points)
An updata since yesterday: when I ignore every fourth byte coming in over USB, everything works perfectly!  But I am hoping to get a definitive answer about where these additional bytes come from, because I need this product to work with any source of MIDI over USB; something that works only in special cases is obviously less than desirable.  I understand it may have nothing whatsoever to do with MIDI Designer, but there may be other MIDI Designer users who run into this issue as well.  Thanks again for any light you may be able to shed on this!
Sorry, I had missed this question. Will respond today and hopefully figure out what's up...

1 Answer

0 votes
 
Best answer
MIDI Designer uses CoreMIDI to send and receive MIDI and the bytes look right to a CoreMIDI receiver on the other end of the line. What you're investigating seems to be the CoreMIDI protocol itself and how it sends over USB. The leading 04 and the way the packets are broken up is outside of MIDI Designer's control, since we don't talk to the iPad Camera Connection Kit indepdendently.

"Can I safely delete every fourth byte?" While this might be right in the present case, inferences from empirical situations might not hold true in the future, etc. If you want to know how CoreMIDI works... get in touch via Config -> Actions -> Email us and we can figure this out together. You should also get another iPad MIDI app to test with (or several).

I hope I've understood the question correctly, and that this answer helps somewhat. Please do get in touch via email and we'll figure this out.

Best!
Dan
by MIDI Designer Team (Dan)
selected by MIDI Designer Team (Dan)
Hi Dan,

Thanks for the reply and info.  I think I found the answer.  I googled "midi over USB" and found this on usb.org

Universal Serial Bus
Device Class Definition
for
MIDI Devices

On page 16:

"MIDI data is transferred over USB using 32-bit USB-MIDI Event Packets. These packets provide an efficient method to transfer multiple MIDI streams with fixed length messages. The 32-bit USB-MIDI Event Packet
allows multiple "virtual MIDI cables"routed over the same USB endpoint. This approach minimizes the number of required endpoints. It also makes parsing MIDI events easier by packetizing the separate bytes of
a MIDI event into one parsed USB-MIDI event.  The first byte in each 32-bit USB-MIDI Event Packet is a Packet Header contains a Cable Number (4 bits) followed by a Code Index Number (4 bits).
The remaining three bytes contain the actual MIDI event."

Then there is a table that shows the meaning of the 4-bit Code Index Number.  04 means "Sysex starts or continues", and 05 means "Single-byte System Common Message, or SysEx ends with following single byte."

So this all makes sense!  This is just how MIDI messages must be sent over USB in order to be understood.

In my case, simply discarding every 4th byte works fine as a preliminary experiment.  In general I think it's not wise because you could receive interleaved MIDI streams on different virtual cables, and if every fourth byte is discarded then multiple messages will be merged together with I would imagine completely unsatisfactory results!  So I think the minimum responsible handling would be to check the cable number in every four-byte packet and make sure they are the same.  If not, blink an LED or something?

Anyway, yes, now it's obvious this has nothing whatsoever to do with MIDI Designer.  

Once upon a time, all MIDI interfaces for computers involved driver installation.  Once MIDI was ratified as a sub-protocol for USB, then it was simply built-in to the PC or Mac or iOS device's USB implementation.  Your device has to enumerate on power-up as a MIDI device (I'm not an expert yet so this is just me trying to explain what I've learned so far), and the host knows what to do with subsequent USB message traffic coming from you.  I guess if you connect to an iOS device using the camera connection kit dongle, and you identify yourself as a MIDI device upon first introductions, then your USB traffic will automatically be routed to Core MIDI thereafter, and apps need only talk to Core MIDI instead of handling the USB connection directly.

Here's to hierarchy!

But I'm just a guy building MIDI equipment in his basement (so far), and I don't have iOS or Core MIDI to handle these things for me.  Ha, I haul my own equipment; I don't have roadies!  So I have to parse the raw USB stream and this is what I found.

I hope this is helpful, but if not, feel free to edit my comments for brevity, clarity, etc., or put them in an appendix, as you see fit.

Steve
Thanks, this is great. We're fortunate to not to have to dive down to that level in MIDI Designer. Glad to see that my guess -- that it would work for this case, but not in all situations -- was pretty much right ;)

Good luck with this endeavor and get in touch if you need further help. Also feel free to get in touch via config -> actions -> email for more direct contact with our support team.

Thanks!
Dan
...