---
title: "MIDIInputPortCreateWithProtocol(_:_:_:_:_:)"
framework: coremidi
role: symbol
role_heading: Function
path: "coremidi/midiinputportcreatewithprotocol(_:_:_:_:_:)"
---

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

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

## Declaration

```swift
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

Return Value An OSStatus result code.

## Discussion

Discussion After creating a port, use 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.

## See Also

### Port management

- [MIDIOutputPortCreate(_:_:_:)](coremidi/midioutputportcreate(_:_:_:).md)
- [MIDIPortDispose(_:)](coremidi/midiportdispose(_:).md)
- [MIDIPortConnectSource(_:_:_:)](coremidi/midiportconnectsource(_:_:_:).md)
- [MIDIPortDisconnectSource(_:_:)](coremidi/midiportdisconnectsource(_:_:).md)
- [MIDIPortRef](coremidi/midiportref.md)
- [MIDIReceiveBlock](coremidi/midireceiveblock.md)
