ultra
ultra

Reputation: 329

How do I send and receive network MIDI data in iOS?

How do I send and receive network MIDI data in iOS? I am able to resolve the server using bonjour and apply the service to a MIDI connection, but I don't know where to go from there. The documentation seems to be lacking, and there's not much information online.

Upvotes: 4

Views: 1865

Answers (1)

Simon Lawrence
Simon Lawrence

Reputation: 574

Essentially, you need to connect to the session via Bonjour as you have done, and within your iOS app:

  • Create a client using MIDIClientCreate
  • Create an input port using MIDIInputPortCreate
    • This takes a pointer to a C function that will be called when MIDI data is received
    • You need to connect it to the MIDINetworkSession's defaultSession using MIDIPortConnectSource - connect it to the sourceEndpoint
  • Create an output port using MIDIOutputPortCreate
    • You can send data to the network session using MIDISend - send the packets to to the MIDINetworkSession defaultSession's destinationEndpoint

I wrote a few blog posts about this a while back, see here for source code etc.

Part 1

Part 2

Part 3

Upvotes: 9

Related Questions