---
title: "MIDIInputPortCreateWithBlock(_:_:_:_:)"
framework: coremidi
role: symbol
role_heading: Function
path: "coremidi/midiinputportcreatewithblock(_:_:_:_:)"
---

# MIDIInputPortCreateWithBlock(_:_:_:_:)

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

## Declaration

```swift
func MIDIInputPortCreateWithBlock(_ client: MIDIClientRef, _ portName: CFString, _ outPort: UnsafeMutablePointer<MIDIPortRef>, _ readBlock: @escaping MIDIReadBlock) -> OSStatus
```

## Parameters

- `client`: The client to own the newly-created port.
- `portName`: The name of the port.
- `outPort`: On successful return, points to the newly-created MIDIPort.
- `readBlock`: The MIDIReadBlock which will be called 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. readBlock will be called on a separate high-priority thread owned by CoreMIDI.

## See Also

### Deprecated Functions

- [MIDIInputPortCreate(_:_:_:_:_:)](coremidi/midiinputportcreate(_:_:_:_:_:).md)
- [MIDISourceCreate(_:_:_:)](coremidi/midisourcecreate(_:_:_:).md)
- [MIDIDestinationCreate(_:_:_:_:_:)](coremidi/mididestinationcreate(_:_:_:_:_:).md)
- [MIDIDestinationCreateWithBlock(_:_:_:_:)](coremidi/mididestinationcreatewithblock(_:_:_:_:).md)
- [MIDIPacketListInit(_:)](coremidi/midipacketlistinit(_:).md)
- [MIDIPacketListAdd(_:_:_:_:_:_:)](coremidi/midipacketlistadd(_:_:_:_:_:_:).md)
- [MIDISend(_:_:_:)](coremidi/midisend(_:_:_:).md)
- [MIDIReceived(_:_:)](coremidi/midireceived(_:_:).md)
- [MIDIReadProc](coremidi/midireadproc.md)
- [MIDIReadBlock](coremidi/midireadblock.md)
