Lately I have been trying to use an app called rtpMIDI to send midi messages (using UDP) to the iPhone over Wifi. This is with my iPhone 3GS (ios 5.0.1) running a CoreMIDI application such as "Argon" or Sampletank Free.

The problem is there is terrible latency, like 0.5sec delays before the note is played. I am using a dedicated router with only my computer and the phone connected to it. I have also tested the wifi by running rtpMIDI on my netbook (since two rtpMIDI clients can connect to each other) and the MIDI streaming is perfect.

So this brings me to the topic subject, since I've identified that there is a problem only on the iPhone, is there any way I can reduce the wifi latency?
One theory I had is it may be background processes like iCloud, Email checking, iMessage checking, and other notifications that are trying to access data over wifi and are clogging the signal. Is there anyway I can kill these background services until reboot?

Well notifications are a pain to toggle on and off on iOS 5 since there's no global on/off switch any more, and I'm pretty sure the iMessage and email checking is going to run in the background regardless. I did however find a neat program called "KillBackground" that lets you kill all the apps that run in the background (the ones you see double tapping the home button), but even after killing all those there was no difference. Just wish I could boot my iPhone into an "iPod touch" kind of mode.

That being said it's all just a theory, there might be something more low level that's wrong with the wifi.

Yeah it uses UDP on Port 5004 over WiFi, bluetooth is disabled on my phone. I was looking to see if it could be done through the DataCable instead but unfortunately there's no easy way to tunnel UDP ports through the Datacable, only TCP ports.

You might want to consider getting "TCP Optimizer", I've used this to open up the network settings (abit like you used to do with windows xp with the half open connections), you might find that delay comes down afterwards. I've used & tested on my devices for a long time now do... Might help you

Hmm, I wonder why there's limits? As for your questions the CoreMIDI spec relies on udp afaik, there's loads of apps that all support CoreMIDI (list here) so whenever one of these apps is running they open up port 5004 udp, I don't know if there's some way to translate it into tcp.

That would be really cool, and I think it is an interesting challenge, the URL for the software is here: rtpMIDI
Unfortunately it isn't open source but there might be some way around that like a proxy, I dunno.
Sampletank Free is the only free app I know of off hand that supports CoreMIDI, there may be others in that list I linked to before if you want to do some testing yourself.

just noticed this thread here and thought, I'd chime in on the subject...

Originally Posted by Susty

Yeah.... The iPhone has UDP limits I seem to recall... Is it imperative to use UDP?

Actually it is. The RTP-MIDI ( RFC 4695 / 6295 ) protocol that Apple is using for both iOS & OS X is based on
RTP-packets which are again based on UDP.

Using TCP for realtime-communication makes not much sense. If you loose a packet and need to take long roundtrips
to request retransmission, the time-frame when this packet will finally arrive is just too late for the real-time constraints.

That is the reason why all the VoIP-stuff is using RTP (and thus UDP) for transmitting media-data.

Originally Posted by Susty

I'm sure I can find something similar that's open source or I can find a program that'll send data upon that port as it's quite a well used one in general I'll keep ya posted.

Like I wrote above, Core MIDI uses the public RTP-MIDI specification (and a proprietary lightweight session protocol to
establish a connection) to transmit MIDI-data.

So you cannot use just any application that sends/receives data on/from this port. rtpMIDI has been developed exactly for the
purpose of connecting via network-MIDI to OS X and iOS devices.

just noticed this thread here and thought, I'd chime in on the subject...

Actually it is. The RTP-MIDI ( RFC 4695 / 6295 ) protocol that Apple is using for both iOS & OS X is based on
RTP-packets which are again based on UDP.

Using TCP for realtime-communication makes not much sense. If you loose a packet and need to take long roundtrips
to request retransmission, the time-frame when this packet will finally arrive is just too late for the real-time constraints.

That is the reason why all the VoIP-stuff is using RTP (and thus UDP) for transmitting media-data.

Like I wrote above, Core MIDI uses the public RTP-MIDI specification (and a proprietary lightweight session protocol to
establish a connection) to transmit MIDI-data.

So you cannot use just any application that sends/receives data on/from this port. rtpMIDI has been developed exactly for the
purpose of connecting via network-MIDI to OS X and iOS devices.

Tobias

Cheers for the heads up there squire Ok, so as you seem to have some knowledge upon the software at hand, the question to ask you then would be what the chances are of making the packets that it sends slightly smaler, therefore meaning that they are more in the iphone's 41k range also

Originally Posted by Qjimbo

Yeah it uses UDP on Port 5004 over WiFi, bluetooth is disabled on my phone. I was looking to see if it could be done through the DataCable instead but unfortunately there's no easy way to tunnel UDP ports through the Datacable, only TCP ports.

Cheers for the heads up there squire Ok, so as you seem to have some knowledge upon the software at hand

Well - I should, as I have actually developed this software ;-)

the question to ask you then would be what the chances are of making the packets that it sends slightly smaler, therefore meaning that they are more in the iphone's 41k range also

Actually RTP-MIDI packets are pretty small. My driver sends an RTP-packet for each single midi-command that I want
to send to the iOS device. The iOS/OS X implementation might package multiple MIDI-commands into a single RTP-MIDI
packet, but since each of those commands is either 1, 2 or 3 bytes long, that does not make much difference...

Would you be able to shed any light on UDP through a datacable?

Well - that would render the cable-less aspect useless, but one can always buy one of the iPhone/iPad MIDI-interfaces
that connect to the dock-connector to go cable-based...

Thanks for your insights Tobias - no doubt you've figured out I'm the same guy who was emailing you about this before! So we've established that the packets are already within the iPhones limitation... but we still have a mystery on our hands here as to why it takes so long for the iPhone to process these UDP packets via WiFi.

Originally Posted by to-pse

Well - that would render the cable-less aspect useless, but one can always buy one of the iPhone/iPad MIDI-interfaces
that connect to the dock-connector to go cable-based...

I'd prefer to avoid spending around $100 for the iRig MIDI and a MIDI-USB adaptor if possible...