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

# MIDISourceCreateWithProtocol(_:_:_:_:)

Creates a virtual source in a client.

```
func MIDISourceCreateWithProtocol(_ client: MIDIClientRef, _ name: CFString, _ protocol: MIDIProtocolID, _ outSrc: UnsafeMutablePointer<MIDIEndpointRef>) -> OSStatus
```

## Parameters

`client`

The client to own the virtual source.

`name`

The name of the virtual source.

`protocol`

The MIDI protocol variant to send from this source. The system automatically converts messages from this protocol to the protocol of the destination.

`outSrc`

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

## 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. After creating a virtual source, use [`MIDIReceivedEventList(_:_:)`](/documentation/CoreMIDI/MIDIReceivedEventList(_:_:)) to transmit MIDI messages from your virtual source to any clients connected to the virtual source.

> 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)