Search This Blog

Tuesday, August 2, 2011

The Apple 30-Pin Misery Plan...

I have been struggling to get high-speed MIDI information out of iOS devices.  Last time I wrote about how the iConnectMIDI failed to give me what I was looking for (I have an email into their support group but so far no follow up response).  Since then - and though I am still playing with that device - I have found another device that I thought would help.

But first I'd like to talk about what I think is going on with iOS and MIDI. 

First off, I believe that the ubiquitous 30-pin Apple USB connector is filled with magic.  In particular there is a "chip" of some sort that resides on one end or the other of the 30-pin that does a lot of magical things for connecting devices.  It is said that there is a patent involved and that anyone wanting to create a cable that is plug-compatible with the iOS devices must use that patented or licensed technology.

There is basically a single USB 2.0 output channel on a given iOS device available via the 30-pin connector.  USB is a high-speed (500 Mb) frame-based architecture and requires two pins on the 30-pin (see this).  Since MIDI output is basically serial output the 30-pin has to share the USB pins and hence the USB.

So what Apple appears to have done was make the iOS devices "look" for MIDI class-compliant devices on the USB line via the Camera Connection kit, if it finds one then it talks to it.

(Note that the Camera Connection Kit only works on iPad at this time.)

However, the USB coming out of the iOS device does not seem to work in the typical USB-daisy-chain mode where you can have multiple devices on a USB line (at least I have not been able to get it to work that way though more testing is required here).  iOS also wants to power the MIDI USB device and, with its battery situation tightly controlled by Apple, the device cannot draw too much power or its rejected.

Next up there is the Apple iOS software talking to the USB port.  The USB line is limited by the iOS drivers available.  The key is here is "class compliant" - if your MIDI device is "class compliant" and draws a minimum of power - it works.  Ditto for various audio interfaces as documented here (I did not try this myself but it makes sense that "class compliant" audio would work as well).  So if some USB device is not known to iOS then it simply isn't recognized or processed.  Add to this the fact that you cannot load drivers into iOS and you end up quite limited.

So the bottom line is that if you want MIDI out of an iOS device you have to use either 1) a Camera Connection Kit on iPad, 2) an iConnectMIDI on any iOS device, or 3) your own solution.

All this leads to something I had hoped to use to solve this: dockStubz from cableJive.

dockStubz is a 30-pin pass through with a mini USB port on the side.  My hope was that MIDI devices connected through the dockStubz via the Camera Connector would work and I could run the debugger.

The device has its own male 30-pin on one end and a female 30-pin on the other.
The mini USB port is on the side.
It connects to the iPhone or iPad and the USB cable works just as if you were using a standard out-of-the-box Apple 30-pin to USB.
It works in XCode just fine.  There's only one rub.  You cannot plug anything else into the 30-pin and have the USB connection work.  So installing the Camera Connection Kit disables and disconnects the mini USB.

Rats!  Some much for believing internet posts about debugging MIDI on the iPad. 

Though now that I have done my research I can see why it doesn't work.  The mini-USB is physically connected to the iOS USB pins on the 30-pin so long as nothing is plugged into the 30-pin.  Plugging in another device breaks that connection.

The other thing that seems to be happening is that when a MIDI device is attached there is some form of throttling going on to ensure that the attached MIDI device is not overrun.  I found this out when a bug in my code had me dumping MIDI CC messages out in a near-tight-loop.

Running these out via my own USB line happens at full USB speed and no throttling occurs (however I am not going through the iOS MIDI driver and instead performing other trickery).

The test will be to determine if MIDI port to MIDI port inside the iOS device is also throttled.  At least on a Mac running 10.6.8 this is not the case - MIDI port to MIDI port seems to run full bore.  My guess is there is some sort of magic happening in the conversion from iOS to USB.

Only more time will tell...

2 comments:

  1. Hello,

    Use a Self powered USB Hub betwwen the USB MIDI Class compliant device and the Apple CCK - this allows you to use many devices which typically IOS5 will not allow you to connect with due to too much power current demands.

    I use this with success on mobile situations:

    Solar Powered USB Hub (ebay)

    ReplyDelete