<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMIDI",
  "identifier" : "/documentation/CoreMIDI/MIDIInputPortCreateWithProtocol(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core MIDI"
    ],
    "preciseIdentifier" : "c:@F@MIDIInputPortCreateWithProtocol"
  },
  "title" : "MIDIInputPortCreateWithProtocol(_:_:_:_:_:)"
}
-->

# MIDIInputPortCreateWithProtocol(_:_:_:_:_:)

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

```
func MIDIInputPortCreateWithProtocol(_ client: MIDIClientRef, _ portName: CFString, _ protocol: MIDIProtocolID, _ outPort: UnsafeMutablePointer<MIDIPortRef>, _ receiveBlock: @escaping MIDIReceiveBlock) -> OSStatus
```

## Parameters

`client`

The client to own the newly created port.

`portName`

The name of the port.

`protocol`

The MIDI protocol variant to deliver to this port. The system automatically converts messages from one protocol to another as needed.

`outPort`

On successful return, points to the newly created MIDI port.

`receiveBlock`

A callback block the system invokes with incoming MIDI from sources connected to this port.

## Return Value

An `OSStatus` result code.

## Discussion

After creating a port, use [`MIDIPortConnectSource(_:_:_:)`](/documentation/CoreMIDI/MIDIPortConnectSource(_:_:_:)) to establish an input connection from any number of sources to your port.

The system calls the receive block on a separate high-priority thread owned by Core MIDI.

---

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)