<!--
{
  "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/MIDIDestinationCreateWithProtocol(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core MIDI"
    ],
    "preciseIdentifier" : "c:@F@MIDIDestinationCreateWithProtocol"
  },
  "title" : "MIDIDestinationCreateWithProtocol(_:_:_:_:_:)"
}
-->

# MIDIDestinationCreateWithProtocol(_:_:_:_:_:)

Creates a virtual destination in a client.

```
func MIDIDestinationCreateWithProtocol(_ client: MIDIClientRef, _ name: CFString, _ protocol: MIDIProtocolID, _ outDest: UnsafeMutablePointer<MIDIEndpointRef>, _ readBlock: @escaping MIDIReceiveBlock) -> OSStatus
```

## Parameters

`client`

The client that owns the virtual destination.

`name`

The name of the virtual destination.

`protocol`

The MIDI protocol variant to deliver to the destination. The system automatically converts messages to this protocol as needed.

`outDest`

On successful return, a pointer to the newly created destination.

`readBlock`

A callback block the system invokes when a client sends MIDI data to the virtual destination.

## Return Value

An `OSStatus` result code.

## Discussion

Drivers don’t need to call this function. When they create devices and entities, the system automatically creates sources and destinations at that time. See [`kMIDIPropertyAdvanceScheduleTimeMuSec`](/documentation/CoreMIDI/kMIDIPropertyAdvanceScheduleTimeMuSec) for information about the relationship between when a sender sends MIDI data to the destination and when it’s received.

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

> Tip:
> After creating a virtual source, assign it the same unique ID it had the last time your app created it. Doing so permits other clients to retain persistent references to your virtual source.

---

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)