<!--
{
  "documentType" : "article",
  "framework" : "CoreMIDI",
  "identifier" : "/documentation/CoreMIDI/midi-services",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "MIDI Services"
}
-->

# MIDI Services

Communicate with hardware using Universal MIDI Packets.

## Discussion

MIDI drivers own and control physical MIDI devices, which include hardware such as USB interfaces, MIDI keyboards, and so on. A MIDI device may have multiple logically distinct subcomponents. For example, one device may contain a MIDI synthesizer and a pair of MIDI ports, both addressable over a USB port. Each element of a device is a MIDI entity.

A MIDI entity can have any number of MIDI endpoints, each of which is a source or destination of a 16-channel MIDI stream. Grouping a device’s endpoints into entities provides the system enough information for an app to make reasonable default assumptions about how to communicate bidirectionally with each entity, as is necessary in MIDI librarian apps.

Core MIDI attaches a collection of properties to each object it manages. Object properties can be:

- Dynamic characteristics of a device, such as MIDI receive channel and system-exclusive (SysEx) IDs.
- Determined by user preference; for example, choice of icon, and whether or not the device appears in lists of possible controllers.
- Static properties that you can’t look up in a database using the device’s manufacturer and model name.

The Core MIDI framework uses interprocess communication (IPC) to communicate with a server process, the MIDI server. The server process in turn loads the MIDI driver and manages all communication with it.

## Topics

### MIDI object configuration

[`MIDIObjectFindByUniqueID(_:_:_:)`](/documentation/CoreMIDI/MIDIObjectFindByUniqueID(_:_:_:))

Locates a device, entity, or endpoint by its unique identifier.

[`MIDIObjectRef`](/documentation/CoreMIDI/MIDIObjectRef)

The common base class for many of the framework’s objects.

[MIDI Object Properties](/documentation/CoreMIDI/midi-object-properties)

Configure the properties of MIDI objects.

### Client management

[Incorporating MIDI 2 into your apps](/documentation/CoreMIDI/incorporating-midi-2-into-your-apps)

Add precision and improve musical control for your MIDI apps.

[`MIDIClientCreate(_:_:_:_:)`](/documentation/CoreMIDI/MIDIClientCreate(_:_:_:_:))

Creates a MIDI client.

[`MIDIClientCreateWithBlock(_:_:_:)`](/documentation/CoreMIDI/MIDIClientCreateWithBlock(_:_:_:))

Creates a MIDI client with a callback block.

[`MIDIClientDispose(_:)`](/documentation/CoreMIDI/MIDIClientDispose(_:))

Disposes of a MIDI client.

[`MIDIClientRef`](/documentation/CoreMIDI/MIDIClientRef)

An object that maintains per-client state.

### Device lookup

[`MIDIGetNumberOfDevices()`](/documentation/CoreMIDI/MIDIGetNumberOfDevices())

Returns the number of devices in the system.

[`MIDIGetDevice(_:)`](/documentation/CoreMIDI/MIDIGetDevice(_:))

Returns a device from the system.

[`MIDIGetNumberOfExternalDevices()`](/documentation/CoreMIDI/MIDIGetNumberOfExternalDevices())

Returns the number of external MIDI devices in the system.

[`MIDIGetExternalDevice(_:)`](/documentation/CoreMIDI/MIDIGetExternalDevice(_:))

Returns one of the external devices in the system.

[`MIDIDeviceGetNumberOfEntities(_:)`](/documentation/CoreMIDI/MIDIDeviceGetNumberOfEntities(_:))

Returns the number of entities in a device.

[`MIDIDeviceGetEntity(_:_:)`](/documentation/CoreMIDI/MIDIDeviceGetEntity(_:_:))

Returns the device’s entity at a specific index.

[`MIDIDeviceRef`](/documentation/CoreMIDI/MIDIDeviceRef)

A MIDI device that contains entities.

### Entity lookup

[`MIDIEntityGetDevice(_:_:)`](/documentation/CoreMIDI/MIDIEntityGetDevice(_:_:))

Returns an entity’s device.

[`MIDIEntityGetNumberOfSources(_:)`](/documentation/CoreMIDI/MIDIEntityGetNumberOfSources(_:))

Returns the number of sources in an entity.

[`MIDIEntityGetSource(_:_:)`](/documentation/CoreMIDI/MIDIEntityGetSource(_:_:))

Returns one of an entity’s sources.

[`MIDIEntityGetNumberOfDestinations(_:)`](/documentation/CoreMIDI/MIDIEntityGetNumberOfDestinations(_:))

Returns the number of destinations in an entity.

[`MIDIEntityGetDestination(_:_:)`](/documentation/CoreMIDI/MIDIEntityGetDestination(_:_:))

Returns one of an entity’s destinations.

[`MIDIEntityRef`](/documentation/CoreMIDI/MIDIEntityRef)

An entity that a device owns and that contains endpoints.

### Port management

[`MIDIInputPortCreateWithProtocol(_:_:_:_:_:)`](/documentation/CoreMIDI/MIDIInputPortCreateWithProtocol(_:_:_:_:_:))

Creates an input port through which the client may receive incoming MIDI messages from any MIDI source.

[`MIDIOutputPortCreate(_:_:_:)`](/documentation/CoreMIDI/MIDIOutputPortCreate(_:_:_:))

Creates an output port through which a client sends outgoing MIDI messages to any MIDI destination.

[`MIDIPortDispose(_:)`](/documentation/CoreMIDI/MIDIPortDispose(_:))

Disposes of a MIDI port.

[`MIDIPortConnectSource(_:_:_:)`](/documentation/CoreMIDI/MIDIPortConnectSource(_:_:_:))

Makes a connection from a source to a client input port.

[`MIDIPortDisconnectSource(_:_:)`](/documentation/CoreMIDI/MIDIPortDisconnectSource(_:_:))

Closes a previously established source-to-input port connection.

[`MIDIPortRef`](/documentation/CoreMIDI/MIDIPortRef)

A MIDI connection that a client maintains.

[`MIDIReceiveBlock`](/documentation/CoreMIDI/MIDIReceiveBlock)

A block receiving MIDI input that includes the incoming messages and a refCon to identify the source.

### Endpoint management

[`MIDIEndpointDispose(_:)`](/documentation/CoreMIDI/MIDIEndpointDispose(_:))

Disposes of a virtual source or destination.

[`MIDIEndpointGetEntity(_:_:)`](/documentation/CoreMIDI/MIDIEndpointGetEntity(_:_:))

Returns an endpoint’s entity.

[`MIDIEndpointGetRefCons(_:_:_:)`](/documentation/CoreMIDI/MIDIEndpointGetRefCons(_:_:_:))

Returns contextual data assigned to an endpoint.

[`MIDIEndpointSetRefCons(_:_:_:)`](/documentation/CoreMIDI/MIDIEndpointSetRefCons(_:_:_:))

Sets contextual data on an endpoint.

[`MIDISourceCreateWithProtocol(_:_:_:_:)`](/documentation/CoreMIDI/MIDISourceCreateWithProtocol(_:_:_:_:))

Creates a virtual source in a client.

[`MIDIGetSource(_:)`](/documentation/CoreMIDI/MIDIGetSource(_:))

Returns a source in the system.

[`MIDIGetNumberOfSources()`](/documentation/CoreMIDI/MIDIGetNumberOfSources())

Returns the number of sources in the system.

[`MIDIDestinationCreateWithProtocol(_:_:_:_:_:)`](/documentation/CoreMIDI/MIDIDestinationCreateWithProtocol(_:_:_:_:_:))

Creates a virtual destination in a client.

[`MIDIGetDestination(_:)`](/documentation/CoreMIDI/MIDIGetDestination(_:))

Returns a destination in the system.

[`MIDIGetNumberOfDestinations()`](/documentation/CoreMIDI/MIDIGetNumberOfDestinations())

Returns the number of destinations in the system.

[`MIDIEndpointRef`](/documentation/CoreMIDI/MIDIEndpointRef)

A MIDI source or destination an entity owns.

### Event list management

[`MIDIEventListInit(_:_:)`](/documentation/CoreMIDI/MIDIEventListInit(_:_:))

Initializes an event list.

[`MIDIEventListAdd(_:_:_:_:_:_:)`](/documentation/CoreMIDI/MIDIEventListAdd(_:_:_:_:_:_:))

Adds an event to an event list.

[`MIDIEventPacketNext(_:)`](/documentation/CoreMIDI/MIDIEventPacketNext(_:))

Advances a packet pointer to the next packet in memory, if the packet is part of an event list.

[`MIDISendEventList(_:_:_:)`](/documentation/CoreMIDI/MIDISendEventList(_:_:_:))

Sends MIDI events to a destination.

[`MIDIReceivedEventList(_:_:)`](/documentation/CoreMIDI/MIDIReceivedEventList(_:_:))

Distributes incoming MIDI events from a source to its connected client input ports.

[`MIDIEventList`](/documentation/CoreMIDI/MIDIEventList)

A variable-length list of MIDI event packets.

[`MIDIEventPacket`](/documentation/CoreMIDI/MIDIEventPacket)

A series of simultaneous MIDI events in Universal MIDI Packets (UMP) format.

[`UnsafeMutableMIDIEventListPointer`](/documentation/CoreMIDI/UnsafeMutableMIDIEventListPointer)

[`UnsafeMutableMIDIEventPacketPointer`](/documentation/CoreMIDI/UnsafeMutableMIDIEventPacketPointer)

### Packet list management

[`MIDIPacketNext(_:)`](/documentation/CoreMIDI/MIDIPacketNext(_:))

Advances a MIDI packet pointer to the next packet in a package list.

[`MIDIPacket`](/documentation/CoreMIDI/MIDIPacket)

A collection of simultaneous MIDI events.

[`MIDIPacketList`](/documentation/CoreMIDI/MIDIPacketList)

A list of MIDI events the system sends to or receives from an endpoint.

[`MIDITimeStamp`](/documentation/CoreMIDI/MIDITimeStamp)

The time on the host clock when the event occurred.

[`UnsafeMutableMIDIPacketListPointer`](/documentation/CoreMIDI/UnsafeMutableMIDIPacketListPointer)

[`UnsafeMutableMIDIPacketPointer`](/documentation/CoreMIDI/UnsafeMutableMIDIPacketPointer)

### I/O management

[`MIDISysexSendRequest`](/documentation/CoreMIDI/MIDISysexSendRequest)

A request to asynchronously send a single system-exclusive (SysEx) event to a destination.

[`MIDISysexSendRequestUMP`](/documentation/CoreMIDI/MIDISysexSendRequestUMP)

A request to asynchronously send a single universal MIDI packet (UMP) system-exclusive (SysEx) event to a destination.

[`MIDIFlushOutput(_:)`](/documentation/CoreMIDI/MIDIFlushOutput(_:))

Cancels all pending events that were previously scheduled to send.

[`MIDIRestart()`](/documentation/CoreMIDI/MIDIRestart())

Stops and restarts MIDI I/O.

[`MIDIIOErrorNotification`](/documentation/CoreMIDI/MIDIIOErrorNotification)

A general I/O error notification.

### Errors

[MIDI Services Errors](/documentation/CoreMIDI/midi-services-errors)

Error codes for Core MIDI operations XX.

### Deprecated

[Deprecated Symbols](/documentation/CoreMIDI/deprecated-symbols)

Review unsupported symbols and their replacements.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)