Guides and Sample Code Developer
Search

CoreMIDI Changes for Swift

CoreMIDI

Added MIDIDriverInterface.init(_reserved: UnsafeMutableRawPointer!, QueryInterface: ( (UnsafeMutableRawPointer?, REFIID, UnsafeMutablePointer<LPVOID?>?) -> HRESULT)!, AddRef: ( (UnsafeMutableRawPointer?) -> ULONG)!, Release: ( (UnsafeMutableRawPointer?) -> ULONG)!, FindDevices: ( (MIDIDriverRef?, MIDIDeviceListRef) -> OSStatus)!, Start: ( (MIDIDriverRef?, MIDIDeviceListRef) -> OSStatus)!, Stop: ( (MIDIDriverRef?) -> OSStatus)!, Configure: ( (MIDIDriverRef?, MIDIDeviceRef) -> OSStatus)!, Send: ( (MIDIDriverRef?, UnsafePointer<MIDIPacketList>?, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> OSStatus)!, EnableSource: ( (MIDIDriverRef?, MIDIEndpointRef, DarwinBoolean) -> OSStatus)!, Flush: ( (MIDIDriverRef?, MIDIEndpointRef, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> OSStatus)!, Monitor: ( (MIDIDriverRef?, MIDIEndpointRef, UnsafePointer<MIDIPacketList>?) -> OSStatus)!)
Declaration
From
struct MIDIDriverInterface {
    var _reserved: UnsafeMutablePointer<Void>
    var QueryInterface: ((UnsafeMutablePointer<Void>, REFIID, UnsafeMutablePointer<LPVOID>) -> HRESULT)!
    var AddRef: ((UnsafeMutablePointer<Void>) -> ULONG)!
    var Release: ((UnsafeMutablePointer<Void>) -> ULONG)!
    var FindDevices: ((MIDIDriverRef, MIDIDeviceListRef) -> OSStatus)!
    var Start: ((MIDIDriverRef, MIDIDeviceListRef) -> OSStatus)!
    var Stop: ((MIDIDriverRef) -> OSStatus)!
    var Configure: ((MIDIDriverRef, MIDIDeviceRef) -> OSStatus)!
    var Send: ((MIDIDriverRef, UnsafePointer<MIDIPacketList>, UnsafeMutablePointer<Void>, UnsafeMutablePointer<Void>) -> OSStatus)!
    var EnableSource: ((MIDIDriverRef, MIDIEndpointRef, DarwinBoolean) -> OSStatus)!
    var Flush: ((MIDIDriverRef, MIDIEndpointRef, UnsafeMutablePointer<Void>, UnsafeMutablePointer<Void>) -> OSStatus)!
    var Monitor: ((MIDIDriverRef, MIDIEndpointRef, UnsafePointer<MIDIPacketList>) -> OSStatus)!
    init()
    init(_reserved _reserved: UnsafeMutablePointer<Void>, QueryInterface QueryInterface: ((UnsafeMutablePointer<Void>, REFIID, UnsafeMutablePointer<LPVOID>) -> HRESULT)!, AddRef AddRef: ((UnsafeMutablePointer<Void>) -> ULONG)!, Release Release: ((UnsafeMutablePointer<Void>) -> ULONG)!, FindDevices FindDevices: ((MIDIDriverRef, MIDIDeviceListRef) -> OSStatus)!, Start Start: ((MIDIDriverRef, MIDIDeviceListRef) -> OSStatus)!, Stop Stop: ((MIDIDriverRef) -> OSStatus)!, Configure Configure: ((MIDIDriverRef, MIDIDeviceRef) -> OSStatus)!, Send Send: ((MIDIDriverRef, UnsafePointer<MIDIPacketList>, UnsafeMutablePointer<Void>, UnsafeMutablePointer<Void>) -> OSStatus)!, EnableSource EnableSource: ((MIDIDriverRef, MIDIEndpointRef, DarwinBoolean) -> OSStatus)!, Flush Flush: ((MIDIDriverRef, MIDIEndpointRef, UnsafeMutablePointer<Void>, UnsafeMutablePointer<Void>) -> OSStatus)!, Monitor Monitor: ((MIDIDriverRef, MIDIEndpointRef, UnsafePointer<MIDIPacketList>) -> OSStatus)!)
}
To
struct MIDIDriverInterface {
    var _reserved: UnsafeMutableRawPointer!
    var QueryInterface: ((UnsafeMutableRawPointer?, REFIID, UnsafeMutablePointer<LPVOID?>?) -> HRESULT)!
    var AddRef: ((UnsafeMutableRawPointer?) -> ULONG)!
    var Release: ((UnsafeMutableRawPointer?) -> ULONG)!
    var FindDevices: ((MIDIDriverRef?, MIDIDeviceListRef) -> OSStatus)!
    var Start: ((MIDIDriverRef?, MIDIDeviceListRef) -> OSStatus)!
    var Stop: ((MIDIDriverRef?) -> OSStatus)!
    var Configure: ((MIDIDriverRef?, MIDIDeviceRef) -> OSStatus)!
    var Send: ((MIDIDriverRef?, UnsafePointer<MIDIPacketList>?, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> OSStatus)!
    var EnableSource: ((MIDIDriverRef?, MIDIEndpointRef, DarwinBoolean) -> OSStatus)!
    var Flush: ((MIDIDriverRef?, MIDIEndpointRef, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> OSStatus)!
    var Monitor: ((MIDIDriverRef?, MIDIEndpointRef, UnsafePointer<MIDIPacketList>?) -> OSStatus)!
    init()
    init(_reserved _reserved: UnsafeMutableRawPointer!, QueryInterface QueryInterface: (@escaping (UnsafeMutableRawPointer?, REFIID, UnsafeMutablePointer<LPVOID?>?) -> HRESULT)!, AddRef AddRef: (@escaping (UnsafeMutableRawPointer?) -> ULONG)!, Release Release: (@escaping (UnsafeMutableRawPointer?) -> ULONG)!, FindDevices FindDevices: (@escaping (MIDIDriverRef?, MIDIDeviceListRef) -> OSStatus)!, Start Start: (@escaping (MIDIDriverRef?, MIDIDeviceListRef) -> OSStatus)!, Stop Stop: (@escaping (MIDIDriverRef?) -> OSStatus)!, Configure Configure: (@escaping (MIDIDriverRef?, MIDIDeviceRef) -> OSStatus)!, Send Send: (@escaping (MIDIDriverRef?, UnsafePointer<MIDIPacketList>?, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> OSStatus)!, EnableSource EnableSource: (@escaping (MIDIDriverRef?, MIDIEndpointRef, DarwinBoolean) -> OSStatus)!, Flush Flush: (@escaping (MIDIDriverRef?, MIDIEndpointRef, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> OSStatus)!, Monitor Monitor: (@escaping (MIDIDriverRef?, MIDIEndpointRef, UnsafePointer<MIDIPacketList>?) -> OSStatus)!)
}

Declaration
From
var AddRef: ((UnsafeMutablePointer<Void>) -> ULONG)!
To
var AddRef: ((UnsafeMutableRawPointer?) -> ULONG)!

Declaration
From
var Configure: ((MIDIDriverRef, MIDIDeviceRef) -> OSStatus)!
To
var Configure: ((MIDIDriverRef?, MIDIDeviceRef) -> OSStatus)!

Declaration
From
var EnableSource: ((MIDIDriverRef, MIDIEndpointRef, DarwinBoolean) -> OSStatus)!
To
var EnableSource: ((MIDIDriverRef?, MIDIEndpointRef, DarwinBoolean) -> OSStatus)!

Declaration
From
var FindDevices: ((MIDIDriverRef, MIDIDeviceListRef) -> OSStatus)!
To
var FindDevices: ((MIDIDriverRef?, MIDIDeviceListRef) -> OSStatus)!

Declaration
From
var Flush: ((MIDIDriverRef, MIDIEndpointRef, UnsafeMutablePointer<Void>, UnsafeMutablePointer<Void>) -> OSStatus)!
To
var Flush: ((MIDIDriverRef?, MIDIEndpointRef, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> OSStatus)!

Declaration
From
var Monitor: ((MIDIDriverRef, MIDIEndpointRef, UnsafePointer<MIDIPacketList>) -> OSStatus)!
To
var Monitor: ((MIDIDriverRef?, MIDIEndpointRef, UnsafePointer<MIDIPacketList>?) -> OSStatus)!

Declaration
From
var QueryInterface: ((UnsafeMutablePointer<Void>, REFIID, UnsafeMutablePointer<LPVOID>) -> HRESULT)!
To
var QueryInterface: ((UnsafeMutableRawPointer?, REFIID, UnsafeMutablePointer<LPVOID?>?) -> HRESULT)!

Declaration
From
var Release: ((UnsafeMutablePointer<Void>) -> ULONG)!
To
var Release: ((UnsafeMutableRawPointer?) -> ULONG)!

Declaration
From
var Send: ((MIDIDriverRef, UnsafePointer<MIDIPacketList>, UnsafeMutablePointer<Void>, UnsafeMutablePointer<Void>) -> OSStatus)!
To
var Send: ((MIDIDriverRef?, UnsafePointer<MIDIPacketList>?, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> OSStatus)!

Declaration
From
var Start: ((MIDIDriverRef, MIDIDeviceListRef) -> OSStatus)!
To
var Start: ((MIDIDriverRef?, MIDIDeviceListRef) -> OSStatus)!

Declaration
From
var Stop: ((MIDIDriverRef) -> OSStatus)!
To
var Stop: ((MIDIDriverRef?) -> OSStatus)!

Declaration
From
enum MIDINotificationMessageID : Int32 {
    case MsgSetupChanged
    case MsgObjectAdded
    case MsgObjectRemoved
    case MsgPropertyChanged
    case MsgThruConnectionsChanged
    case MsgSerialPortOwnerChanged
    case MsgIOError
}
To
enum MIDINotificationMessageID : Int32 {
    case msgSetupChanged
    case msgObjectAdded
    case msgObjectRemoved
    case msgPropertyChanged
    case msgThruConnectionsChanged
    case msgSerialPortOwnerChanged
    case msgIOError
}

Declaration
From
case MsgIOError
To
case msgIOError

Declaration
From
case MsgObjectAdded
To
case msgObjectAdded

Declaration
From
case MsgObjectRemoved
To
case msgObjectRemoved

Declaration
From
case MsgPropertyChanged
To
case msgPropertyChanged

Declaration
From
case MsgSerialPortOwnerChanged
To
case msgSerialPortOwnerChanged

Declaration
From
case MsgSetupChanged
To
case msgSetupChanged

Declaration
From
case MsgThruConnectionsChanged
To
case msgThruConnectionsChanged

Declaration
From
enum MIDIObjectType : Int32 {
    case Other
    case Device
    case Entity
    case Source
    case Destination
    case ExternalDevice
    case ExternalEntity
    case ExternalSource
    case ExternalDestination
}
To
enum MIDIObjectType : Int32 {
    case other
    case device
    case entity
    case source
    case destination
    case externalDevice
    case externalEntity
    case externalSource
    case externalDestination
}

Declaration
From
case Destination
To
case destination

Declaration
From
case Device
To
case device

Declaration
From
case Entity
To
case entity

Declaration
From
case ExternalDestination
To
case externalDestination

Declaration
From
case ExternalDevice
To
case externalDevice

Declaration
From
case ExternalEntity
To
case externalEntity

Declaration
From
case ExternalSource
To
case externalSource

Declaration
From
case Other
To
case other

Declaration
From
case Source
To
case source

Declaration
From
struct MIDISysexSendRequest {
    var destination: MIDIEndpointRef
    var data: UnsafePointer<UInt8>
    var bytesToSend: UInt32
    var complete: DarwinBoolean
    var reserved: (UInt8, UInt8, UInt8)
    var completionProc: MIDICompletionProc
    var completionRefCon: UnsafeMutablePointer<Void>
}
To
struct MIDISysexSendRequest {
    var destination: MIDIEndpointRef
    var data: UnsafePointer<UInt8>
    var bytesToSend: UInt32
    var complete: DarwinBoolean
    var reserved: (UInt8, UInt8, UInt8)
    var completionProc: CoreMIDI.MIDICompletionProc
    var completionRefCon: UnsafeMutableRawPointer?
}

Declaration
From
var completionProc: MIDICompletionProc
To
var completionProc: CoreMIDI.MIDICompletionProc

Declaration
From
var completionRefCon: UnsafeMutablePointer<Void>
To
var completionRefCon: UnsafeMutableRawPointer?

Declaration
From
enum MIDITransformControlType : UInt8 {
    case ControlType_7Bit
    case ControlType_14Bit
    case ControlType_7BitRPN
    case ControlType_14BitRPN
    case ControlType_7BitNRPN
    case ControlType_14BitNRPN
}
To
enum MIDITransformControlType : UInt8 {
    case controlType_7Bit
    case controlType_14Bit
    case controlType_7BitRPN
    case controlType_14BitRPN
    case controlType_7BitNRPN
    case controlType_14BitNRPN
}

Declaration
From
case ControlType_14Bit
To
case controlType_14Bit

Declaration
From
case ControlType_14BitNRPN
To
case controlType_14BitNRPN

Declaration
From
case ControlType_14BitRPN
To
case controlType_14BitRPN

Declaration
From
case ControlType_7Bit
To
case controlType_7Bit

Declaration
From
case ControlType_7BitNRPN
To
case controlType_7BitNRPN

Declaration
From
case ControlType_7BitRPN
To
case controlType_7BitRPN

Declaration
From
enum MIDITransformType : UInt16 {
    case None
    case FilterOut
    case MapControl
    case Add
    case Scale
    case MinValue
    case MaxValue
    case MapValue
}
To
enum MIDITransformType : UInt16 {
    case none
    case filterOut
    case mapControl
    case add
    case scale
    case minValue
    case maxValue
    case mapValue
}

Declaration
From
case Add
To
case add

Declaration
From
case FilterOut
To
case filterOut

Declaration
From
case MapControl
To
case mapControl

Declaration
From
case MapValue
To
case mapValue

Declaration
From
case MaxValue
To
case maxValue

Declaration
From
case MinValue
To
case minValue

Declaration
From
case None
To
case none

Declaration
From
case Scale
To
case scale

Declaration
From
func MIDIClientCreate(_ name: CFString, _ notifyProc: MIDINotifyProc?, _ notifyRefCon: UnsafeMutablePointer<Void>, _ outClient: UnsafeMutablePointer<MIDIClientRef>) -> OSStatus
To
func MIDIClientCreate(_ name: CFString, _ notifyProc: CoreMIDI.MIDINotifyProc?, _ notifyRefCon: UnsafeMutableRawPointer?, _ outClient: UnsafeMutablePointer<MIDIClientRef>) -> OSStatus

Declaration
From
func MIDIClientCreateWithBlock(_ name: CFString, _ outClient: UnsafeMutablePointer<MIDIClientRef>, _ notifyBlock: MIDINotifyBlock?) -> OSStatus
To
func MIDIClientCreateWithBlock(_ name: CFString, _ outClient: UnsafeMutablePointer<MIDIClientRef>, _ notifyBlock: CoreMIDI.MIDINotifyBlock?) -> OSStatus

Declaration
From
typealias MIDICompletionProc = (UnsafeMutablePointer<MIDISysexSendRequest>) -> Void
To
typealias MIDICompletionProc = (UnsafeMutablePointer<MIDISysexSendRequest>) -> Swift.Void

Declaration
From
func MIDIDestinationCreate(_ client: MIDIClientRef, _ name: CFString, _ readProc: MIDIReadProc, _ refCon: UnsafeMutablePointer<Void>, _ outDest: UnsafeMutablePointer<MIDIEndpointRef>) -> OSStatus
To
func MIDIDestinationCreate(_ client: MIDIClientRef, _ name: CFString, _ readProc: CoreMIDI.MIDIReadProc, _ refCon: UnsafeMutableRawPointer?, _ outDest: UnsafeMutablePointer<MIDIEndpointRef>) -> OSStatus

Declaration
From
func MIDIDestinationCreateWithBlock(_ client: MIDIClientRef, _ name: CFString, _ outDest: UnsafeMutablePointer<MIDIEndpointRef>, _ readBlock: MIDIReadBlock) -> OSStatus
To
func MIDIDestinationCreateWithBlock(_ client: MIDIClientRef, _ name: CFString, _ outDest: UnsafeMutablePointer<MIDIEndpointRef>, _ readBlock: CoreMIDI.MIDIReadBlock) -> OSStatus

Declaration
From
func MIDIDeviceCreate(_ owner: MIDIDriverRef, _ name: CFString!, _ manufacturer: CFString!, _ model: CFString!, _ outDevice: UnsafeMutablePointer<MIDIDeviceRef>) -> OSStatus
To
func MIDIDeviceCreate(_ owner: MIDIDriverRef!, _ name: CFString!, _ manufacturer: CFString!, _ model: CFString!, _ outDevice: UnsafeMutablePointer<MIDIDeviceRef>!) -> OSStatus

Declaration
From
func MIDIDriverEnableMonitoring(_ driver: MIDIDriverRef, _ enabled: Bool) -> OSStatus
To
func MIDIDriverEnableMonitoring(_ driver: MIDIDriverRef!, _ enabled: Bool) -> OSStatus

Modified MIDIDriverRef
Declaration
From
typealias MIDIDriverRef = UnsafeMutablePointer<UnsafeMutablePointer<MIDIDriverInterface>>
To
typealias MIDIDriverRef = UnsafeMutablePointer<UnsafeMutablePointer<MIDIDriverInterface>?>

Declaration
From
func MIDIEndpointGetEntity(_ inEndpoint: MIDIEndpointRef, _ outEntity: UnsafeMutablePointer<MIDIEntityRef>) -> OSStatus
To
func MIDIEndpointGetEntity(_ inEndpoint: MIDIEndpointRef, _ outEntity: UnsafeMutablePointer<MIDIEntityRef>?) -> OSStatus

Declaration
From
func MIDIEndpointGetRefCons(_ endpt: MIDIEndpointRef, _ ref1: UnsafeMutablePointer<UnsafeMutablePointer<Void>>, _ ref2: UnsafeMutablePointer<UnsafeMutablePointer<Void>>) -> OSStatus
To
func MIDIEndpointGetRefCons(_ endpt: MIDIEndpointRef, _ ref1: UnsafeMutablePointer<UnsafeMutableRawPointer?>!, _ ref2: UnsafeMutablePointer<UnsafeMutableRawPointer?>!) -> OSStatus

Declaration
From
func MIDIEndpointSetRefCons(_ endpt: MIDIEndpointRef, _ ref1: UnsafeMutablePointer<Void>, _ ref2: UnsafeMutablePointer<Void>) -> OSStatus
To
func MIDIEndpointSetRefCons(_ endpt: MIDIEndpointRef, _ ref1: UnsafeMutableRawPointer!, _ ref2: UnsafeMutableRawPointer!) -> OSStatus

Declaration
From
func MIDIEntityGetDevice(_ inEntity: MIDIEntityRef, _ outDevice: UnsafeMutablePointer<MIDIDeviceRef>) -> OSStatus
To
func MIDIEntityGetDevice(_ inEntity: MIDIEntityRef, _ outDevice: UnsafeMutablePointer<MIDIDeviceRef>?) -> OSStatus

Declaration
From
func MIDIGetDriverDeviceList(_ driver: MIDIDriverRef) -> MIDIDeviceListRef
To
func MIDIGetDriverDeviceList(_ driver: MIDIDriverRef!) -> MIDIDeviceListRef

Declaration
From
func MIDIInputPortCreate(_ client: MIDIClientRef, _ portName: CFString, _ readProc: MIDIReadProc, _ refCon: UnsafeMutablePointer<Void>, _ outPort: UnsafeMutablePointer<MIDIPortRef>) -> OSStatus
To
func MIDIInputPortCreate(_ client: MIDIClientRef, _ portName: CFString, _ readProc: CoreMIDI.MIDIReadProc, _ refCon: UnsafeMutableRawPointer?, _ outPort: UnsafeMutablePointer<MIDIPortRef>) -> OSStatus

Declaration
From
func MIDIInputPortCreateWithBlock(_ client: MIDIClientRef, _ portName: CFString, _ outPort: UnsafeMutablePointer<MIDIPortRef>, _ readBlock: MIDIReadBlock) -> OSStatus
To
func MIDIInputPortCreateWithBlock(_ client: MIDIClientRef, _ portName: CFString, _ outPort: UnsafeMutablePointer<MIDIPortRef>, _ readBlock: CoreMIDI.MIDIReadBlock) -> OSStatus

Declaration
From
typealias MIDINotifyBlock = (UnsafePointer<MIDINotification>) -> Void
To
typealias MIDINotifyBlock = (UnsafePointer<MIDINotification>) -> Swift.Void

Declaration
From
typealias MIDINotifyProc = (UnsafePointer<MIDINotification>, UnsafeMutablePointer<Void>) -> Void
To
typealias MIDINotifyProc = (UnsafePointer<MIDINotification>, UnsafeMutableRawPointer?) -> Swift.Void

Declaration
From
func MIDIObjectFindByUniqueID(_ inUniqueID: MIDIUniqueID, _ outObject: UnsafeMutablePointer<MIDIObjectRef>, _ outObjectType: UnsafeMutablePointer<MIDIObjectType>) -> OSStatus
To
func MIDIObjectFindByUniqueID(_ inUniqueID: MIDIUniqueID, _ outObject: UnsafeMutablePointer<MIDIObjectRef>?, _ outObjectType: UnsafeMutablePointer<MIDIObjectType>?) -> OSStatus

Declaration
From
func MIDIPortConnectSource(_ port: MIDIPortRef, _ source: MIDIEndpointRef, _ connRefCon: UnsafeMutablePointer<Void>) -> OSStatus
To
func MIDIPortConnectSource(_ port: MIDIPortRef, _ source: MIDIEndpointRef, _ connRefCon: UnsafeMutableRawPointer?) -> OSStatus

Modified MIDIReadBlock
Declaration
From
typealias MIDIReadBlock = (UnsafePointer<MIDIPacketList>, UnsafeMutablePointer<Void>) -> Void
To
typealias MIDIReadBlock = (UnsafePointer<MIDIPacketList>, UnsafeMutableRawPointer?) -> Swift.Void

Modified MIDIReadProc
Declaration
From
typealias MIDIReadProc = (UnsafePointer<MIDIPacketList>, UnsafeMutablePointer<Void>, UnsafeMutablePointer<Void>) -> Void
To
typealias MIDIReadProc = (UnsafePointer<MIDIPacketList>, UnsafeMutableRawPointer?, UnsafeMutableRawPointer?) -> Swift.Void

Declaration
From
func MIDIThruConnectionFind(_ inPersistentOwnerID: CFString, _ outConnectionList: UnsafeMutablePointer<Unmanaged<CFData>?>) -> OSStatus
To
func MIDIThruConnectionFind(_ inPersistentOwnerID: CFString, _ outConnectionList: UnsafeMutablePointer<Unmanaged<CFData>>) -> OSStatus

Declaration
From
func MIDIThruConnectionGetParams(_ connection: MIDIThruConnectionRef, _ outConnectionParams: UnsafeMutablePointer<Unmanaged<CFData>?>) -> OSStatus
To
func MIDIThruConnectionGetParams(_ connection: MIDIThruConnectionRef, _ outConnectionParams: UnsafeMutablePointer<Unmanaged<CFData>>) -> OSStatus

Feedback