iOS Developer Library

Developer

CoreMIDI Framework Reference MIDI Services Reference

Options
Deployment Target:

On This Page
Language:

MIDI Services Reference

MIDI drivers own and control MIDI devices, which include such things as USB interfaces, MIDI keyboards, and so on. A device is defined as a physical object that would be represented by a single icon if there were a graphical view of the studio.

A MIDI device may have multiple logically distinct sub-components. For example, one device may encompass a MIDI synthesizer and a pair of MIDI ports, both addressable via a USB port. Each such element of a device is called a MIDI entity.

A MIDI entity can have any number of MIDI endpoints, each of which is a source or destination of a 16-channel MIDI stream. By grouping a device’s endpoints into entities, the system has enough information for an application to make reasonable default assumptions about how to communicate in a bi-directional manner with each entity, as is necessary in MIDI librarian applications.

Core MIDI attaches a collection of properties to each object it manages. Some properties are dynamic characteristics of a device—such as MIDI receive channel and system-exclusive IDs. Other properties are a matter of user preference—such as choice of icon, and whether or not the device should appear in lists of possible controllers. Still other properties are static and could be looked up in a database, using the device’s manufacturer and model names as a key.

The Core MIDI framework uses IPC (interprocess communication) to communicate with a server process, the MIDI server. The server process in turn loads, and manages all communication with, the MIDI driver.

Beginning in iOS 6, apps need to have the audio key in their UIBackgroundModes in order to use CoreMIDI’s MIDISourceCreate and MIDIDestinationCreate functions. These functions return kMIDINotPermitted (-10844) if the key is not set. See Information Property List Key Reference for more information.

Functions

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

    Declaration

    Swift

    func MIDIInputPortCreate(_ client: MIDIClient!, _ portName: CFString!, _ readProc: MIDIReadProc, _ refCon: UnsafeMutablePointer<Void>, _ outPort: UnsafeMutablePointer<Unmanaged<MIDIPort>?>) -> OSStatus

    Objective-C

    OSStatus MIDIInputPortCreate ( MIDIClientRef client, CFStringRef portName, MIDIReadProc readProc, void *refCon, MIDIPortRef *outPort );

    Parameters

    client

    The client to own the newly-created port.

    portName

    The name of the port.

    readProc

    The MIDIReadProc which will be called with incoming MIDI, from sources connected to this port.

    refCon

    The refCon passed to readHook.

    outPort

    On successful return, points to the newly-created MIDIPort.

    Return Value

    A result code.

    Discussion

    After creating a port, use MIDIPortConnectSource to establish an input connection from any number of sources to your port.

    readProc will be called on a separate high-priority thread owned by CoreMIDI.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Creates an output port through which the client may send outgoing MIDI messages to any MIDI destination.

    Declaration

    Swift

    func MIDIOutputPortCreate(_ client: MIDIClient!, _ portName: CFString!, _ outPort: UnsafeMutablePointer<Unmanaged<MIDIPort>?>) -> OSStatus

    Objective-C

    OSStatus MIDIOutputPortCreate ( MIDIClientRef client, CFStringRef portName, MIDIPortRef *outPort );

    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.

    Return Value

    A result code.

    Discussion

    Output ports provide a mechanism for MIDI merging. CoreMIDI assumes that each output port will be responsible for sending only a single MIDI stream to each destination, although a single port may address all of the destinations in the system.

    Multiple output ports are only necessary when an application is capable of directing multiple simultaneous MIDI streams to the same destination.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Establishes a connection from a source to a client's input port.

    Declaration

    Swift

    func MIDIPortConnectSource(_ port: MIDIPort!, _ source: MIDIEndpoint!, _ connRefCon: UnsafeMutablePointer<Void>) -> OSStatus

    Objective-C

    OSStatus MIDIPortConnectSource ( MIDIPortRef port, MIDIEndpointRef source, void *connRefCon );

    Parameters

    port

    The port to which to create the connection. This port's readProc is called with incoming MIDI from the source.

    source

    The source from which to create the connection.

    connRefCon

    This refCon is passed to the MIDIReadProc, as a way to identify the source.

    Return Value

    A result code.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Closes a previously-established source-to-input port connection.

    Declaration

    Swift

    func MIDIPortDisconnectSource(_ port: MIDIPort!, _ source: MIDIEndpoint!) -> OSStatus

    Objective-C

    OSStatus MIDIPortDisconnectSource ( MIDIPortRef port, MIDIEndpointRef source );

    Parameters

    port

    The port whose connection is being closed.

    source

    The source from which to close a connection to the specified port.

    Return Value

    A result code.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Disposes a MIDIPort object.

    Declaration

    Swift

    func MIDIPortDispose(_ port: MIDIPort!) -> OSStatus

    Objective-C

    OSStatus MIDIPortDispose ( MIDIPortRef port );

    Parameters

    port

    The port to dispose.

    Return Value

    A result code.

    Discussion

    It is not usually necessary to call this function; when an application's MIDIClient's are automatically disposed at termination, or explicitly, via MIDIClientDispose, the client's ports are automatically disposed at that time.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Adds a MIDI event to a MIDIPacketList.

    Declaration

    Swift

    func MIDIPacketListAdd(_ pktlist: UnsafeMutablePointer<MIDIPacketList>, _ listSize: ByteCount, _ curPacket: UnsafeMutablePointer<MIDIPacket>, _ time: MIDITimeStamp, _ nData: ByteCount, _ data: UnsafePointer<Byte>) -> UnsafeMutablePointer<MIDIPacket>

    Objective-C

    MIDIPacket * MIDIPacketListAdd ( MIDIPacketList *pktlist, ByteCount listSize, MIDIPacket *curPacket, MIDITimeStamp time, ByteCount nData, const Byte *data );

    Parameters

    pktlist

    The packet list to which the event is to be added.

    listSize

    The size, in bytes, of the packet list.

    curPacket

    A packet pointer returned by a previous call to MIDIPacketListInit or MIDIPacketListAdd for this packet list.

    time

    The new event's time.

    nData

    The length of the new event, in bytes.

    data

    The new event. May be a single MIDI event, or a partial sys-ex event. Running status is not permitted.

    Return Value

    Returns null if there was not room in the packet for the event; otherwise returns a packet pointer which should be passed as curPacket in a subsequent call to this function.

    Discussion

    The maximum size of a packet list is 65536 bytes. Large sysex messages must be sent in smaller packet lists.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Prepares a MIDIPacketList to be built up dynamically.

    Declaration

    Swift

    func MIDIPacketListInit(_ pktlist: UnsafeMutablePointer<MIDIPacketList>) -> UnsafeMutablePointer<MIDIPacket>

    Objective-C

    MIDIPacket * MIDIPacketListInit ( MIDIPacketList *pktlist );

    Parameters

    pktlist

    The packet list to be initialized.

    Return Value

    A pointer to the first MIDIPacket in the packet list.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Advances a MIDIPacket pointer to the MIDIPacket that immediately follows a given packet in memory, for packets that are part of a MIDIPacketList array.

    Declaration

    Objective-C

    (MIDIPacket *) MIDIPacketNext ( MIDIPacket *pkt );

    Parameters

    pkt

    A pointer to a MIDIPacket in a MIDIPacketList array.

    Return Value

    The subsequent packet in the MIDIPacketList array.

    Discussion

    This is implemented as a macro for efficiency and to avoid const problems. Refer to the MIDIServices.h header file for the macro implementation.

  • Locates a device, external device, entity, or endpoint by its uniqueID.

    Declaration

    Swift

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

    Objective-C

    OSStatus MIDIObjectFindByUniqueID ( MIDIUniqueID inUniqueID, MIDIObjectRef *outObject, MIDIObjectType *outObjectType );

    Parameters

    inUniqueID

    The uniqueID of the object to search for. (This should be the result of an earlier call to MIDIObjectGetIntegerProperty for the property kMIDIPropertyUniqueID).

    outObject

    The returned object, or NULL if the object was not found or an error occurred. This should be cast to the appropriate type (MIDIDeviceRef, MIDIEntityRef, MIDIEndpointRef), according to *outObjectType.

    outObjectType

    On exit, the type of object which was found; undefined if none found.

    Return Value

    An OSStatus error code, including kMIDIObjectNotFound if there is no object with the specified uniqueID.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Gets an object's data-type property.

    Declaration

    Swift

    func MIDIObjectGetDataProperty(_ obj: MIDIObjectRef, _ propertyID: CFString!, _ outData: UnsafeMutablePointer<Unmanaged<CFData>?>) -> OSStatus

    Objective-C

    OSStatus MIDIObjectGetDataProperty ( MIDIObjectRef obj, CFStringRef propertyID, CFDataRef *outData );

    Parameters

    obj

    The object whose property is to be returned.

    propertyID

    Name of the property to return.

    outData

    On successful return, the value of the property.

    Return Value

    A result code.

    Discussion

    (See the MIDIObjectRef documentation for information about properties.)

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Gets an object's dictionary-type property.

    Declaration

    Swift

    func MIDIObjectGetDictionaryProperty(_ obj: MIDIObjectRef, _ propertyID: CFString!, _ outDict: UnsafeMutablePointer<Unmanaged<CFDictionary>?>) -> OSStatus

    Objective-C

    OSStatus MIDIObjectGetDictionaryProperty ( MIDIObjectRef obj, CFStringRef propertyID, CFDictionaryRef *outDict );

    Parameters

    obj

    The object whose property is to be returned.

    propertyID

    Name of the property to return.

    outDict

    On successful return, the value of the property.

    Return Value

    A result code.

    Discussion

    (See the MIDIObjectRef documentation for information about properties.)

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Gets an object's integer-type property.

    Declaration

    Swift

    func MIDIObjectGetIntegerProperty(_ obj: MIDIObjectRef, _ propertyID: CFString!, _ outValue: UnsafeMutablePointer<Int32>) -> OSStatus

    Objective-C

    OSStatus MIDIObjectGetIntegerProperty ( MIDIObjectRef obj, CFStringRef propertyID, SInt32 *outValue );

    Parameters

    obj

    The object whose property is to be returned.

    propertyID

    Name of the property to return.

    outValue

    On successful return, the value of the property.

    Return Value

    A result code.

    Discussion

    (See the MIDIObjectRef documentation for information about properties.)

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Gets all of an object's properties.

    Declaration

    Swift

    func MIDIObjectGetProperties(_ obj: MIDIObjectRef, _ outProperties: UnsafeMutablePointer<Unmanaged<CFPropertyList>?>, _ deep: Boolean) -> OSStatus

    Objective-C

    OSStatus MIDIObjectGetProperties ( MIDIObjectRef obj, CFPropertyListRef *outProperties, Boolean deep );

    Parameters

    obj

    The object whose properties are to be returned.

    outProperties

    On successful return, the object's properties.

    deep

    true if the object's child objects are to be included (e.g. a device's entities, or an entity's endpoints).

    Return Value

    A result code.

    Discussion

    Returns a CFPropertyList of all of an object's properties. The property list may be a dictionary or an array. Dictionaries map property names (CFString) to values, which may be CFNumber, CFString, or CFData. Arrays are arrays of such values.

    Properties which an object inherits from its owning object (if any) are not included.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Gets an object's string-type property.

    Declaration

    Swift

    func MIDIObjectGetStringProperty(_ obj: MIDIObjectRef, _ propertyID: CFString!, _ str: UnsafeMutablePointer<Unmanaged<CFString>?>) -> OSStatus

    Objective-C

    OSStatus MIDIObjectGetStringProperty ( MIDIObjectRef obj, CFStringRef propertyID, CFStringRef *str );

    Parameters

    obj

    The object whose property is to be returned.

    propertyID

    Name of the property to return.

    str

    On successful return, the value of the property.

    Return Value

    A result code.

    Discussion

    (See the MIDIObjectRef documentation for information about properties.)

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Removes an object's property.

    Declaration

    Swift

    func MIDIObjectRemoveProperty(_ obj: MIDIObjectRef, _ propertyID: CFString!) -> OSStatus

    Objective-C

    OSStatus MIDIObjectRemoveProperty ( MIDIObjectRef obj, CFStringRef propertyID );

    Parameters

    obj

    The object whose property is to be removed.

    propertyID

    The property to be removed.

    Return Value

    A result code.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Sets an object's data-type property.

    Declaration

    Swift

    func MIDIObjectSetDataProperty(_ obj: MIDIObjectRef, _ propertyID: CFString!, _ data: CFData!) -> OSStatus

    Objective-C

    OSStatus MIDIObjectSetDataProperty ( MIDIObjectRef obj, CFStringRef propertyID, CFDataRef data );

    Parameters

    obj

    The object whose property is to be altered.

    propertyID

    Name of the property to set.

    data

    New value of the property.

    Return Value

    A result code.

    Discussion

    (See the MIDIObjectRef documentation for information about properties.)

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Sets an object's dictionary-type property.

    Declaration

    Swift

    func MIDIObjectSetDictionaryProperty(_ obj: MIDIObjectRef, _ propertyID: CFString!, _ dict: CFDictionary!) -> OSStatus

    Objective-C

    OSStatus MIDIObjectSetDictionaryProperty ( MIDIObjectRef obj, CFStringRef propertyID, CFDictionaryRef data );

    Parameters

    obj

    The object whose property is to be altered.

    propertyID

    Name of the property to set.

    dict

    New value of the property.

    Return Value

    A result code.

    Discussion

    (See the MIDIObjectRef documentation for information about properties.)

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Sets an object's integer-type property.

    Declaration

    Swift

    func MIDIObjectSetIntegerProperty(_ obj: MIDIObjectRef, _ propertyID: CFString!, _ value: Int32) -> OSStatus

    Objective-C

    OSStatus MIDIObjectSetIntegerProperty ( MIDIObjectRef obj, CFStringRef propertyID, SInt32 value );

    Parameters

    obj

    The object whose property is to be altered.

    propertyID

    Name of the property to set.

    value

    New value of the property.

    Return Value

    A result code.

    Discussion

    (See the MIDIObjectRef documentation for information about properties.)

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Sets an object's string-type property.

    Declaration

    Swift

    func MIDIObjectSetStringProperty(_ obj: MIDIObjectRef, _ propertyID: CFString!, _ str: CFString!) -> OSStatus

    Objective-C

    OSStatus MIDIObjectSetStringProperty ( MIDIObjectRef obj, CFStringRef propertyID, CFStringRef str );

    Parameters

    obj

    The object whose property is to be altered.

    propertyID

    Name of the property to set.

    str

    New value of the property.

    Return Value

    A result code.

    Discussion

    (See the MIDIObjectRef documentation for information about properties.)

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Unschedules previously-sent packets.

    Declaration

    Swift

    func MIDIFlushOutput(_ dest: MIDIEndpoint!) -> OSStatus

    Objective-C

    OSStatus MIDIFlushOutput ( MIDIEndpointRef dest );

    Parameters

    dest

    All pending events scheduled to be sent to this destination are unscheduled. If NULL, the operation applies to all destinations.

    Discussion

    Clients may use MIDIFlushOutput to cancel the sending of packets that were previously scheduled for future delivery.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Distributes incoming MIDI from a source to the client input ports which are connected to that source.

    Declaration

    Swift

    func MIDIReceived(_ src: MIDIEndpoint!, _ pktlist: UnsafePointer<MIDIPacketList>) -> OSStatus

    Objective-C

    OSStatus MIDIReceived ( MIDIEndpointRef src, const MIDIPacketList *pktlist );

    Parameters

    src

    The source which is transmitting MIDI.

    pktlist

    The MIDI events to be transmitted.

    Return Value

    A result code.

    Discussion

    Drivers should call this function when receiving MIDI from a source.

    Clients which have created virtual sources, using MIDISourceCreate, should call this function when the source is generating MIDI.

    Unlike MIDISend(), a timestamp of 0 is not equivalent to "now"; the driver or virtual source is responsible for putting proper timestamps in the packets.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Stops and restarts MIDI I/O.

    Declaration

    Swift

    func MIDIRestart() -> OSStatus

    Objective-C

    OSStatus MIDIRestart ( void );

    Return Value

    A result code.

    Discussion

    This is useful for forcing CoreMIDI to ask its drivers to rescan for hardware.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Sends MIDI to a destination.

    Declaration

    Swift

    func MIDISend(_ port: MIDIPort!, _ dest: MIDIEndpoint!, _ pktlist: UnsafePointer<MIDIPacketList>) -> OSStatus

    Objective-C

    OSStatus MIDISend ( MIDIPortRef port, MIDIEndpointRef dest, const MIDIPacketList *pktlist );

    Parameters

    port

    The output port through which the MIDI is to be sent.

    dest

    The destination to receive the events.

    pktlist

    The MIDI events to be sent.

    Return Value

    A result code.

    Discussion

    Events with future timestamps are scheduled for future delivery. CoreMIDI performs any needed MIDI merging.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Sends a single system-exclusive event, asynchronously.

    Declaration

    Swift

    func MIDISendSysex(_ request: UnsafeMutablePointer<MIDISysexSendRequest>) -> OSStatus

    Objective-C

    OSStatus MIDISendSysex ( MIDISysexSendRequest *request );

    Parameters

    request

    Contains the destination, and a pointer to the MIDI data to be sent.

    Return Value

    A result code.

    Discussion

    request->data must point to a single MIDI system-exclusive message, or portion thereof.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns one of the external devices in the system.

    Declaration

    Swift

    func MIDIGetExternalDevice(_ deviceIndex0: ItemCount) -> Unmanaged<MIDIDevice>!

    Objective-C

    MIDIDeviceRef MIDIGetExternalDevice ( ItemCount deviceIndex0 );

    Parameters

    deviceIndex0

    The index (0...MIDIGetNumberOfDevices()-1) of the device to return.

    Return Value

    A reference to a device, or NULL if an error occurred.

    Discussion

    Use this to enumerate the external devices in the system.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns the number of external MIDI devices in the system.

    Declaration

    Swift

    func MIDIGetNumberOfExternalDevices() -> ItemCount

    Objective-C

    ItemCount MIDIGetNumberOfExternalDevices ( void );

    Return Value

    The number of external devices in the system, or 0 if an error occurred.

    Discussion

    External MIDI devices are MIDI devices connected to driver endpoints via a standard MIDI cable. Their presence is completely optional, only when a UI (such as Audio MIDI Setup) adds them.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns one of a given entity's destinations.

    Declaration

    Swift

    func MIDIEntityGetDestination(_ entity: MIDIEntity!, _ destIndex0: ItemCount) -> Unmanaged<MIDIEndpoint>!

    Objective-C

    MIDIEndpointRef MIDIEntityGetDestination ( MIDIEntityRef entity, ItemCount destIndex0 );

    Parameters

    entity

    The entity being queried.

    destIndex0

    The index (0...MIDIEntityGetNumberOfDestinations(entity) - 1) of the destination to return

    Return Value

    A reference to a destination, or NULL if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns an entity's device.

    Declaration

    Swift

    func MIDIEntityGetDevice(_ inEntity: MIDIEntity!, _ outDevice: UnsafeMutablePointer<Unmanaged<MIDIDevice>?>) -> OSStatus

    Objective-C

    OSStatus MIDIEntityGetDevice ( MIDIEntityRef inEntity, MIDIDeviceRef *outDevice );

    Parameters

    inEntity

    The entity being queried.

    outDevice

    On successful return, the entity's owning device.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns the number of destinations in a given entity.

    Declaration

    Swift

    func MIDIEntityGetNumberOfDestinations(_ entity: MIDIEntity!) -> ItemCount

    Objective-C

    ItemCount MIDIEntityGetNumberOfDestinations ( MIDIEntityRef entity );

    Parameters

    entity

    The entity being queried

    Return Value

    The number of destinations the entity contains, or 0 if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns the number of sources in a given entity.

    Declaration

    Swift

    func MIDIEntityGetNumberOfSources(_ entity: MIDIEntity!) -> ItemCount

    Objective-C

    ItemCount MIDIEntityGetNumberOfSources ( MIDIEntityRef entity );

    Parameters

    entity

    The entity being queried

    Return Value

    The number of sources the entity contains, or 0 if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns one of a given entity's sources.

    Declaration

    Swift

    func MIDIEntityGetSource(_ entity: MIDIEntity!, _ sourceIndex0: ItemCount) -> Unmanaged<MIDIEndpoint>!

    Objective-C

    MIDIEndpointRef MIDIEntityGetSource ( MIDIEntityRef entity, ItemCount sourceIndex0 );

    Parameters

    entity

    The entity being queried.

    sourceIndex0

    The index (0...MIDIEntityGetNumberOfSources(entity)-1) of the source to return

    Return Value

    A reference to a source, or NULL if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Creates a virtual destination in a client.

    Declaration

    Swift

    func MIDIDestinationCreate(_ client: MIDIClient!, _ name: CFString!, _ readProc: MIDIReadProc, _ refCon: UnsafeMutablePointer<Void>, _ outDest: UnsafeMutablePointer<Unmanaged<MIDIEndpoint>?>) -> OSStatus

    Objective-C

    OSStatus MIDIDestinationCreate ( MIDIClientRef client, CFStringRef name, MIDIReadProc readProc, void *refCon, MIDIEndpointRef *outDest );

    Parameters

    client

    The client owning the virtual destination.

    name

    The name of the virtual destination.

    readProc

    The MIDIReadProc to be called when a client sends MIDI to the virtual destination.

    refCon

    The refCon to be passed to the readProc.

    outDest

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

    Return Value

    A result code.

    Discussion

    The specified readProc gets called when clients send MIDI to your virtual destination.

    Drivers need not call this; when they create devices and entities, sources and destinations are created at that time.

    After creating a virtual destination, it's a good idea to assign it the same unique ID it had the last time your application created it. (Although you should be prepared for this to fail in the unlikely event of a collision.) This will permit other clients to retain persistent references to your virtual destination more easily.

    See the discussion of kMIDIPropertyAdvanceScheduleTimeMuSec for notes about the relationship between when a sender sends MIDI to the destination and when it is received.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Disposes a virtual source or destination your client created.

    Declaration

    Swift

    func MIDIEndpointDispose(_ endpt: MIDIEndpoint!) -> OSStatus

    Objective-C

    OSStatus MIDIEndpointDispose ( MIDIEndpointRef endpt );

    Parameters

    endpt

    The endpoint to be disposed.

    Return Value

    A result code.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns an endpoint's entity.

    Declaration

    Swift

    func MIDIEndpointGetEntity(_ inEndpoint: MIDIEndpoint!, _ outEntity: UnsafeMutablePointer<Unmanaged<MIDIEntity>?>) -> OSStatus

    Objective-C

    OSStatus MIDIEndpointGetEntity ( MIDIEndpointRef inEndpoint, MIDIEntityRef *outEntity );

    Parameters

    inEndpoint

    The endpoint being queried.

    outEntity

    On exit, the endpoint's owning entity, or NULL if none.

    Discussion

    Virtual sources and destinations don't have entities.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns one of the destinations in the system.

    Declaration

    Swift

    func MIDIGetDestination(_ destIndex0: ItemCount) -> Unmanaged<MIDIEndpoint>!

    Objective-C

    MIDIEndpointRef MIDIGetDestination ( ItemCount destIndex0 );

    Parameters

    destIndex0

    The index (0...MIDIGetNumberOfDestinations()-1) of the destination to return

    Return Value

    A reference to a destination, or NULL if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns the number of destinations in the system.

    Declaration

    Swift

    func MIDIGetNumberOfDestinations() -> ItemCount

    Objective-C

    ItemCount MIDIGetNumberOfDestinations ( void );

    Return Value

    The number of destinations in the system, or 0 if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns the number of sources in the system.

    Declaration

    Swift

    func MIDIGetNumberOfSources() -> ItemCount

    Objective-C

    ItemCount MIDIGetNumberOfSources ( void );

    Return Value

    The number of sources in the system, or 0 if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns one of the sources in the system.

    Declaration

    Swift

    func MIDIGetSource(_ sourceIndex0: ItemCount) -> Unmanaged<MIDIEndpoint>!

    Objective-C

    MIDIEndpointRef MIDIGetSource ( ItemCount sourceIndex0 );

    Parameters

    sourceIndex0

    The index (0...MIDIGetNumberOfSources()-1) of the source to return

    Return Value

    A reference to a source, or NULL if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Creates a virtual source in a client.

    Declaration

    Swift

    func MIDISourceCreate(_ client: MIDIClient!, _ name: CFString!, _ outSrc: UnsafeMutablePointer<Unmanaged<MIDIEndpoint>?>) -> OSStatus

    Objective-C

    OSStatus MIDISourceCreate ( MIDIClientRef client, CFStringRef name, MIDIEndpointRef *outSrc );

    Parameters

    client

    The client owning the virtual source.

    name

    The name of the virtual source.

    outSrc

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

    Return Value

    A result code.

    Discussion

    Drivers need not call this; when they create devices and entities, sources and destinations are created at that time.

    After creating a virtual source, use MIDIReceived to transmit MIDI messages from your virtual source to any clients connected to the virtual source.

    After creating a virtual source, it's a good idea to assign it the same unique ID it had the last time your application created it. (Although you should be prepared for this to fail in the unlikely event of a collision.) This will permit other clients to retain persistent references to your virtual source more easily.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns one of a given device's entities.

    Declaration

    Swift

    func MIDIDeviceGetEntity(_ device: MIDIDevice!, _ entityIndex0: ItemCount) -> Unmanaged<MIDIEntity>!

    Objective-C

    MIDIEntityRef MIDIDeviceGetEntity ( MIDIDeviceRef device, ItemCount entityIndex0 );

    Parameters

    device

    The device being queried.

    entityIndex0

    The index (0...MIDIDeviceGetNumberOfEntities(device)-1) of the entity to return

    Return Value

    A reference to an entity, or NULL if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns the number of entities in a given device.

    Declaration

    Swift

    func MIDIDeviceGetNumberOfEntities(_ device: MIDIDevice!) -> ItemCount

    Objective-C

    ItemCount MIDIDeviceGetNumberOfEntities ( MIDIDeviceRef device );

    Parameters

    device

    The device being queried.

    Return Value

    The number of entities the device contains, or 0 if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns one of the devices in the system.

    Declaration

    Swift

    func MIDIGetDevice(_ deviceIndex0: ItemCount) -> Unmanaged<MIDIDevice>!

    Objective-C

    MIDIDeviceRef MIDIGetDevice ( ItemCount deviceIndex0 );

    Parameters

    deviceIndex0

    The index (0...MIDIGetNumberOfDevices()-1) of the device to return.

    Return Value

    A reference to a device, or NULL if an error occurred.

    Discussion

    Use this to enumerate the devices in the system.

    To enumerate the entities in the system, you can walk through the devices, then walk through the devices' entities.

    Note: If a client iterates through the devices and entities in the system, it will not ever visit any virtual sources and destinations created by other clients. Also, a device iteration will return devices which are "offline" (were present in the past but are not currently present), while iterations through the system's sources and destinations will not include the endpoints of offline devices.

    Thus clients should usually use MIDIGetNumberOfSources, MIDIGetSource, MIDIGetNumberOfDestinations and MIDIGetDestination, rather iterating through devices and entities to locate endpoints.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Returns the number of devices in the system.

    Declaration

    Swift

    func MIDIGetNumberOfDevices() -> ItemCount

    Objective-C

    ItemCount MIDIGetNumberOfDevices ( void );

    Return Value

    The number of devices in the system, or 0 if an error occurred.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Creates a MIDIClient object.

    Declaration

    Swift

    func MIDIClientCreate(_ name: CFString!, _ notifyProc: MIDINotifyProc, _ notifyRefCon: UnsafeMutablePointer<Void>, _ outClient: UnsafeMutablePointer<Unmanaged<MIDIClient>?>) -> OSStatus

    Objective-C

    OSStatus MIDIClientCreate ( CFStringRef name, MIDINotifyProc notifyProc, void *notifyRefCon, MIDIClientRef *outClient );

    Parameters

    name

    The client's name.

    notifyProc

    An optional (may be NULL) callback function through which the client will receive notifications of changes to the system.

    notifyRefCon

    A refCon passed back to notifyRefCon

    outClient

    On successful return, points to the newly-created MIDIClientRef.

    Return Value

    A result code.

    Discussion

    Note that notifyProc will always be called on the run loop which was current when MIDIClientCreate was first called.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Disposes a MIDIClient object.

    Declaration

    Swift

    func MIDIClientDispose(_ client: MIDIClient!) -> OSStatus

    Objective-C

    OSStatus MIDIClientDispose ( MIDIClientRef client );

    Parameters

    client

    The client to dispose.

    Return Value

    A result code.

    Discussion

    It is not essential to call this function; the CoreMIDI framework will automatically dispose all MIDIClients when an application terminates.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

Callbacks

  • Called when a MIDI system-exclusive event has been completely sent or has been aborted.

    Declaration

    Swift

    typealias MIDICompletionProc = CFunctionPointer<((UnsafeMutablePointer<MIDISysexSendRequest>) -> Void)>

    Objective-C

    typedef void (*MIDICompletionProc) ( MIDISysexSendRequest *request );

    Parameters

    request

    The MIDISysexSendRequest which has completed, or been aborted.

    Discussion

    Use this callback function to notify your app of the completion of a call to the MIDISendSysex function.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Called when the MIDI state changes.

    Declaration

    Swift

    typealias MIDINotifyProc = CFunctionPointer<((UnsafePointer<MIDINotification>, UnsafeMutablePointer<Void>) -> Void)>

    Objective-C

    typedef void (*MIDINotifyProc) ( const MIDINotification *message, void *refCon );

    Parameters

    message

    Information about the state change.

    refCon

    The context you provided to the MIDIClientCreate function.

    Discussion

    The MIDINotifyProc callback function is invoked on the same thread on which you called the MIDIClientCreate function.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Called when the system has one or more incoming MIDI messages to deliver to your app.

    Declaration

    Swift

    typealias MIDIReadProc = CFunctionPointer<((UnsafePointer<MIDIPacketList>, UnsafeMutablePointer<Void>, UnsafeMutablePointer<Void>) -> Void)>

    Objective-C

    typedef void (*MIDIReadProc) ( const MIDIPacketList *pktlist, void *readProcRefCon, void *srcConnRefCon );

    Parameters

    pktlist

    The incoming MIDI message or messages.

    readProcRefCon

    The context you provided to the MIDIInputPortCreate or MIDIDestinationCreate function.

    srcConnRefCon

    The context you provided to the MIDIPortConnectSource function, which identifies the source of the data.

    Discussion

    When you call the MIDIInputPortCreate or MIDIDestinationCreate function, you provide a pointer to your MIDIReadProc callback. The system creates a high-priority receive thread on your behalf. Because your MIDIReadProc callback is invoked from a separate thread, be aware of the synchronization issues when using data provided by this callback.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

Data Types

  • An object maintaining per-client state.

    Declaration

    Swift

    typealias MIDIClientRef = MIDIClient

    Objective-C

    typedef MIDIObjectRef MIDIClientRef;

    Discussion

    Derives from MIDIObjectRef, does not have an owner object.

    To use CoreMIDI, an application creates a MIDIClientRef, to which it can add MIDIPortRef's, through which it can send and receive MIDI.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • A MIDI device or external device, containing entities.

    Declaration

    Swift

    typealias MIDIDeviceRef = MIDIDevice

    Objective-C

    typedef MIDIObjectRef MIDIDeviceRef;

    Discussion

    Derives from MIDIObjectRef, does not have an owner object.

    A MIDI device, which either attaches directly to the computer and is controlled by a MIDI driver, or which is "external," meaning that it is connected to a driver-controlled device via a standard MIDI cable.

    A MIDIDeviceRef has properties and contains MIDIEntityRef's.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • A MIDI source or destination, owned by an entity.

    Declaration

    Swift

    typealias MIDIEndpointRef = MIDIEndpoint

    Objective-C

    typedef MIDIObjectRef MIDIEndpointRef;

    Discussion

    Derives from MIDIObjectRef, owned by a MIDIEntityRef, unless it is a virtual endpoint, in which case there is no owning entity.

    Entities have any number of MIDIEndpointRef's, sources and destinations of 16-channel MIDI streams.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • A MIDI entity, owned by a device, containing endpoints.

    Declaration

    Swift

    typealias MIDIEntityRef = MIDIEntity

    Objective-C

    typedef MIDIObjectRef MIDIEntityRef;

    Discussion

    Derives from MIDIObjectRef, owned by a MIDIDeviceRef.

    Devices may have multiple logically distinct sub-components, e.g. a MIDI synthesizer and a pair of MIDI ports, both addressable via a USB port.

    By grouping a device's endpoints into entities, the system has enough information for an application to make reasonable assumptions about how to communicate in a bi-directional manner with each entity, as is desirable in MIDI librarian applications.

    These sub-components are MIDIEntityRef's.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • The base class of many CoreMIDI objects.

    Declaration

    Swift

    typealias MIDIObjectRef = UnsafeMutablePointer<Void>

    Objective-C

    typedef UInt32 MIDIObjectRef;

    Discussion

    MIDIObject is the base class for many of the objects in CoreMIDI. They have properties, and often an "owner" object, from which they inherit any properties they do not themselves have.

    Developers may add their own private properties, whose names must begin with their company's inverted domain name, as in Java package names, but with underscores instead of dots, e.g.: com_apple_APrivateAppleProperty

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • A MIDI connection port owned by a client.

    Declaration

    Swift

    typealias MIDIPortRef = MIDIPort

    Objective-C

    typedef MIDIObjectRef MIDIPortRef;

    Discussion

    Derives from MIDIObjectRef, owned by a MIDIClientRef.

    A MIDIPortRef, which may be an input port or output port, is an object through which a client may communicate with any number of MIDI sources or destinations.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • A host clock time.

    Declaration

    Swift

    typealias MIDITimeStamp = UInt64

    Objective-C

    typedef UInt64 MIDITimeStamp;

    Discussion

    A host clock time representing the time of an event, as returned by mach_absolute_time() or UpTime().

    Since MIDI applications will tend to do a fair amount of math with the times of events, it's more convenient to use a UInt64 than an AbsoluteTime.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • A unique identifier for a MIDIObjectRef.

    Declaration

    Swift

    typealias MIDIUniqueID = Int32

    Objective-C

    typedef SInt32 MIDIUniqueID;

    Discussion

    An integer which uniquely identifies a MIDIObjectRef.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • A message describing a system state change.

    Declaration

    Swift

    struct MIDINotification { var messageID: MIDINotificationMessageID var messageSize: UInt32 }

    Objective-C

    struct MIDINotification { MIDINotificationMessageID messageID; UInt32 messageSize; // additional data may follow, depending on messageID }; typedef struct MIDINotification MIDINotification;

    Fields

    messageID

    type of message

    messageSize

    size of the entire message, including messageID and messageSize

    Discussion

    A MIDINotification is a structure passed to a MIDINotifyProc, when CoreMIDI wishes to inform a client of a change in the state of the system.

    Availability

    Available in iOS 4.2 and later.

  • A message describing the addition or removal of an object.

    Declaration

    Swift

    struct MIDIObjectAddRemoveNotification { var messageID: MIDINotificationMessageID var messageSize: UInt32 var parent: MIDIObjectRef var parentType: MIDIObjectType var child: MIDIObjectRef var childType: MIDIObjectType }

    Objective-C

    struct MIDIObjectAddRemoveNotification { MIDINotificationMessageID messageID; UInt32 messageSize; MIDIObjectRef parent; MIDIObjectType parentType; MIDIObjectRef child; MIDIObjectType childType; }; typedef struct MIDIObjectAddRemoveNotification MIDIObjectAddRemoveNotification;

    Fields

    messageID

    type of message

    messageSize

    size of the entire message, including messageID and messageSize

    parent

    the parent of the added or removed object (possibly NULL)

    parentType

    the type of the parent object (undefined if parent is NULL)

    child

    the added or removed object

    childType

    the type of the added or removed object

    Discussion

    Availability

    Available in iOS 4.2 and later.

  • A message describing the addition or removal of an object.

    Declaration

    Swift

    struct MIDIObjectPropertyChangeNotification { var messageID: MIDINotificationMessageID var messageSize: UInt32 var object: MIDIObjectRef var objectType: MIDIObjectType var propertyName: Unmanaged<CFString>! }

    Objective-C

    struct MIDIObjectPropertyChangeNotification { MIDINotificationMessageID messageID; UInt32 messageSize; MIDIObjectRef object; MIDIObjectType objectType; CFStringRef propertyName; }; typedef struct MIDIObjectPropertyChangeNotification MIDIObjectPropertyChangeNotification;

    Fields

    messageID

    The type of message.

    messageSize

    The size of the entire message, including the messageID and messageSize fields.

    object

    The object whose property has changed.

    objectType

    The type of the object whose property has changed.

    propertyName

    The name of the changed property.

    Availability

    Available in iOS 4.2 and later.

  • A message describing a MIDI I/O error.

    Declaration

    Swift

    struct MIDIIOErrorNotification { var messageID: MIDINotificationMessageID var messageSize: UInt32 var driverDevice: Unmanaged<MIDIDevice>! var errorCode: OSStatus }

    Objective-C

    struct MIDIIOErrorNotification { MIDINotificationMessageID messageID; UInt32 messageSize; MIDIDeviceRef driverDevice; OSStatus errorCode; }; typedef struct MIDIIOErrorNotification MIDIIOErrorNotification;

    Fields

    messageID

    The type of message.

    messageSize

    The size of the entire message, including the messageID and messageSize fields.

    driverDevice

    The I/O driver that exhibited an error.

    errorCode

    An error code.

    Availability

    Available in iOS 4.2 and later.

  • A collection of simultaneous MIDI events.

    Declaration

    Swift

    struct MIDIPacket { var timeStamp: MIDITimeStamp var length: UInt16 var data: (Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte) }

    Objective-C

    struct MIDIPacket { MIDITimeStamp timeStamp; UInt16 length; Byte data[256]; }; typedef struct MIDIPacket MIDIPacket;

    Fields

    timeStamp

    The time at which the events occurred, if receiving MIDI, or, if sending MIDI, the time at which the events are to be played. Zero means "now." The time stamp applies to the first MIDI byte in the packet.

    length

    The number of valid MIDI bytes which follow, in data. (It may be larger than 256 bytes if the packet is dynamically allocated.)

    data

    A variable-length stream of MIDI messages. Running status is not allowed. In the case of system-exclusive messages, a packet may only contain a single message, or portion of one, with no other MIDI events.

    Discussion

    The MIDI messages in the packet must always be complete, except for system-exclusive.

    (This is declared to be 256 bytes in length so clients don't have to create custom data structures in simple situations.)

    Availability

    Available in iOS 4.2 and later.

  • A list of MIDI events being received from, or being sent to, one endpoint.

    Declaration

    Swift

    struct MIDIPacketList { var numPackets: UInt32 var packet: (MIDIPacket) }

    Objective-C

    struct MIDIPacketList { UInt32 numPackets; MIDIPacket packet[1]; }; typedef struct MIDIPacketList MIDIPacketList;

    Fields

    numPackets

    The number of MIDIPackets in the list.

    packet

    An open-ended array of variable-length MIDIPackets.

    Discussion

    The timestamps in the packet list must be in ascending order.

    Note that the packets in the list, while defined as an array, may not be accessed as an array, since they are variable-length. To iterate through the packets in a packet list, use a loop such as:

    • MIDIPacket *packet = &packetList->packet[0];
    • for (int i = 0; i > packetList->numPackets; ++i) {
    • // ...
    • packet = MIDIPacketNext (packet);
    • }

    Availability

    Available in iOS 4.2 and later.

  • A request to transmit a system-exclusive event.

    Declaration

    Swift

    struct MIDISysexSendRequest { var destination: Unmanaged<MIDIEndpoint>! var data: UnsafePointer<Byte> var bytesToSend: UInt32 var complete: Boolean var reserved: (Byte, Byte, Byte) var completionProc: MIDICompletionProc var completionRefCon: UnsafeMutablePointer<Void> }

    Objective-C

    struct MIDISysexSendRequest { MIDIEndpointRef destination; const Byte *data; UInt32 bytesToSend; Boolean complete; Byte reserved[3]; MIDICompletionProc completionProc; void *completionRefCon; }; typedef struct MIDISysexSendRequest MIDISysexSendRequest;

    Fields

    destination

    The endpoint to which the event is to be sent.

    data

    Initially, a pointer to the sys-ex event to be sent. MIDISendSysex will advance this pointer as bytes are sent.

    bytesToSend

    Initially, the number of bytes to be sent. MIDISendSysex will decrement this counter as bytes are sent.

    complete

    The client may set this to true at any time to abort transmission. The implementation sets this to true when all bytes have been sent.

    completionProc

    Called when all bytes have been sent, or after the client has set complete to true.

    completionRefCon

    Passed as a refCon to completionProc.

    Discussion

    This represents a request to send a single system-exclusive MIDI event to a MIDI destination asynchronously.

    Availability

    Available in iOS 4.2 and later.

Constants

  • Declaration

    Swift

    let kMIDIPropertyAdvanceScheduleTimeMuSec: CFString! let kMIDIPropertyCanRoute: CFString! let kMIDIPropertyConnectionUniqueID: CFString! let kMIDIPropertyDeviceID: CFString! let kMIDIPropertyDisplayName: CFString! let kMIDIPropertyDriverDeviceEditorApp: CFString! let kMIDIPropertyDriverOwner: CFString! let kMIDIPropertyDriverVersion: CFString! let kMIDIPropertyImage: CFString! let kMIDIPropertyIsBroadcast: CFString! let kMIDIPropertyIsDrumMachine: CFString! let kMIDIPropertyIsEffectUnit: CFString! let kMIDIPropertyIsEmbeddedEntity: CFString! let kMIDIPropertyIsMixer: CFString! let kMIDIPropertyIsSampler: CFString! let kMIDIPropertyManufacturer: CFString! let kMIDIPropertyMaxReceiveChannels: CFString! let kMIDIPropertyMaxSysExSpeed: CFString! let kMIDIPropertyMaxTransmitChannels: CFString! let kMIDIPropertyModel: CFString! let kMIDIPropertyName: CFString! let kMIDIPropertyNameConfiguration: CFString! let kMIDIPropertyOffline: CFString! let kMIDIPropertyPanDisruptsStereo: CFString! let kMIDIPropertyPrivate: CFString! let kMIDIPropertyReceiveChannels: CFString! let kMIDIPropertyReceivesBankSelectLSB: CFString! let kMIDIPropertyReceivesBankSelectMSB: CFString! let kMIDIPropertyReceivesClock: CFString! let kMIDIPropertyReceivesMTC: CFString! let kMIDIPropertyReceivesNotes: CFString! let kMIDIPropertyReceivesProgramChanges: CFString! let kMIDIPropertySingleRealtimeEntity: CFString! let kMIDIPropertySupportsGeneralMIDI: CFString! let kMIDIPropertySupportsMMC: CFString! let kMIDIPropertySupportsShowControl: CFString! let kMIDIPropertyTransmitChannels: CFString! let kMIDIPropertyTransmitsBankSelectLSB: CFString! let kMIDIPropertyTransmitsBankSelectMSB: CFString! let kMIDIPropertyTransmitsClock: CFString! let kMIDIPropertyTransmitsMTC: CFString! let kMIDIPropertyTransmitsNotes: CFString! let kMIDIPropertyTransmitsProgramChanges: CFString! let kMIDIPropertyUniqueID: CFString!

    Objective-C

    const CFStringRef kMIDIPropertyAdvanceScheduleTimeMuSec; const CFStringRef kMIDIPropertyCanRoute; const CFStringRef kMIDIPropertyConnectionUniqueID; const CFStringRef kMIDIPropertyDeviceID; const CFStringRef kMIDIPropertyDisplayName; const CFStringRef kMIDIPropertyDriverDeviceEditorApp; const CFStringRef kMIDIPropertyDriverOwner; const CFStringRef kMIDIPropertyDriverVersion; const CFStringRef kMIDIPropertyImage; const CFStringRef kMIDIPropertyIsBroadcast; const CFStringRef kMIDIPropertyIsDrumMachine; const CFStringRef kMIDIPropertyIsEffectUnit; const CFStringRef kMIDIPropertyIsEmbeddedEntity; const CFStringRef kMIDIPropertyIsMixer; const CFStringRef kMIDIPropertyIsSampler; const CFStringRef kMIDIPropertyManufacturer; const CFStringRef kMIDIPropertyMaxReceiveChannels; const CFStringRef kMIDIPropertyMaxSysExSpeed; const CFStringRef kMIDIPropertyMaxTransmitChannels; const CFStringRef kMIDIPropertyModel; const CFStringRef kMIDIPropertyName; const CFStringRef kMIDIPropertyNameConfiguration; const CFStringRef kMIDIPropertyOffline; const CFStringRef kMIDIPropertyPanDisruptsStereo; const CFStringRef kMIDIPropertyPrivate; const CFStringRef kMIDIPropertyReceiveChannels; const CFStringRef kMIDIPropertyReceivesBankSelectLSB; const CFStringRef kMIDIPropertyReceivesBankSelectMSB; const CFStringRef kMIDIPropertyReceivesClock; const CFStringRef kMIDIPropertyReceivesMTC; const CFStringRef kMIDIPropertyReceivesNotes; const CFStringRef kMIDIPropertyReceivesProgramChanges; const CFStringRef kMIDIPropertySingleRealtimeEntity; const CFStringRef kMIDIPropertySupportsGeneralMIDI; const CFStringRef kMIDIPropertySupportsMMC; const CFStringRef kMIDIPropertySupportsShowControl; const CFStringRef kMIDIPropertyTransmitChannels; const CFStringRef kMIDIPropertyTransmitsBankSelectLSB; const CFStringRef kMIDIPropertyTransmitsBankSelectMSB; const CFStringRef kMIDIPropertyTransmitsClock; const CFStringRef kMIDIPropertyTransmitsMTC; const CFStringRef kMIDIPropertyTransmitsNotes; const CFStringRef kMIDIPropertyTransmitsProgramChanges; const CFStringRef kMIDIPropertyUniqueID;

    Constants

    • kMIDIPropertyAdvanceScheduleTimeMuSec

      kMIDIPropertyAdvanceScheduleTimeMuSec

      device/entity/endpoint property, integer

      Set by the owning driver; should not be touched by other clients. If it is non-zero, then it is a recommendation of how many microseconds in advance clients should schedule output. Clients should treat this value as a minimum. For devices with a non-zero advance schedule time, drivers will receive outgoing messages to the device at the time they are sent by the client, via MIDISend, and the driver is responsible for scheduling events to be played at the right times according to their timestamps.

      As of CoreMIDI 1.3, this property may also be set on virtual destinations (but only the creator of the destination should do so). When a client sends to a virtual destination with an advance schedule time of 0, the virtual destination receives its messages at their scheduled delivery time. If a virtual destination has a non-zero advance schedule time, it receives timestamped messages as soon as they are sent, and must do its own internal scheduling of received events.

      Available in iOS 4.2 and later.

    • kMIDIPropertyCanRoute

      kMIDIPropertyCanRoute

      // e.g. is patch bay

      device/entity property, integer (0/1). Indicates whether the device or entity can route MIDI messages to or from other external MIDI devices (as with MIDI patch bays). This should NOT be set on devices which are controlled by drivers.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyConnectionUniqueID

      kMIDIPropertyConnectionUniqueID

      device/entity/endpoint property, integer or CFDataRef

      UniqueID of an external device/entity/endpoint attached to this one. As of Mac OS X 10.3, Audio MIDI Setup maintains endpoint-to-external endpoint connections (in 10.2, it connected devices to devices). The property is non-existant or 0 if there is no connection.

      New for CoreMIDI 1.1 (Mac OS X 10.1)

      Beginning with CoreMIDI 1.3, this property may also be a CFDataRef containing an array of big-endian SInt32's, to allow specifying that a driver object connects to multiple external objects (via MIDI thru-ing or splitting).

      This property may also exist for external devices/entities/endpoints, in which case it signifies a MIDI Thru connection to another external device/entity/endpoint (again, it is strongly recommended that it be an endpoint).

      Available in iOS 4.2 and later.

    • kMIDIPropertyDeviceID

      kMIDIPropertyDeviceID

      device/entity property, integer

      The entity's system-exclusive ID, in user-visible form

      Drivers may set this property on their devices or entities.

      Setup editors may allow the user to set this property on external devices.

      Available in iOS 4.2 and later.

    • kMIDIPropertyDisplayName

      kMIDIPropertyDisplayName

      device/entity/endpoint property, string.

      Provides the Apple-recommended user-visible name for an endpoint, by combining the device and endpoint names.

      For objects other than endpoints, the display name is the same as the name.

      New for CoreMIDI 1.5.

      Available in iOS 4.2 and later.

    • kMIDIPropertyDriverDeviceEditorApp

      kMIDIPropertyDriverDeviceEditorApp

      device property, string, contains the full path to an application which knows how to configure this driver-owned devices. Drivers may set this property on their owned devices. Applications must not write to it.

      New for CoreMIDI 1.4.

      Available in iOS 4.2 and later.

    • kMIDIPropertyDriverOwner

      kMIDIPropertyDriverOwner

      device/entity/endpoint property, string

      Name of the driver that owns a device. Set by the owning driver, on the device; should not be touched by other clients. Property is inherited from the device by its entities and endpoints.

      New for CoreMIDI 1.1 (Mac OS X 10.1)

      Available in iOS 4.2 and later.

    • kMIDIPropertyDriverVersion

      kMIDIPropertyDriverVersion

      device/entity/endpoint property, integer, returns the driver version API of the owning driver (only for driver- owned devices). Drivers need not set this property; applications should not write to it.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyImage

      kMIDIPropertyImage

      device property, CFStringRef which is a full POSIX path to a device or external device's icon, stored in any standard graphic file format such as JPEG, GIF, PNG and TIFF are all acceptable. (See CFURL for functions to convert between POSIX paths and other ways of specifying files.) The image's maximum size should be 128x128.

      Drivers should set the icon on the devices they add.

      A studio setup editor should allow the user to choose icons for external devices.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyIsBroadcast

      kMIDIPropertyIsBroadcast

      entity/endpoint property, integer

      1 if the endpoint broadcasts messages to all of the other endpoints in the device, 0 if not. Set by the owning driver; should not be touched by other clients. New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyIsDrumMachine

      kMIDIPropertyIsDrumMachine

      device/entity property, integer (0/1). Indicates whether the device or entity's sound presets tend to be collections of non-transposable samples (e.g. drum kits).

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyIsEffectUnit

      kMIDIPropertyIsEffectUnit

      device/entity property, integer (0/1). Indicates whether the device or entity is primarily a MIDI-controlled audio effect unit (i.e. does not generate sound on its own).

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyIsEmbeddedEntity

      kMIDIPropertyIsEmbeddedEntity

      entity/endpoint property, integer

      0 if there are external MIDI connectors, 1 if not. New for CoreMIDI 1.1 (Mac OS X 10.1)

      Available in iOS 4.2 and later.

    • kMIDIPropertyIsMixer

      kMIDIPropertyIsMixer

      device/entity property, integer (0/1). Indicates whether the device or entity mixes external audio signals, controlled by MIDI messages.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyIsSampler

      kMIDIPropertyIsSampler

      device/entity property, integer (0/1). Indicates whether the device or entity plays audio samples in response to MIDI note messages.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyManufacturer

      kMIDIPropertyManufacturer

      device/endpoint property, string

      Drivers should set this property on their devices.

      Setup editors may allow the user to set this property on external devices.

      Creators of virtual endpoints may set this property on their endpoints.

      Available in iOS 4.2 and later.

    • kMIDIPropertyMaxReceiveChannels

      kMIDIPropertyMaxReceiveChannels

      device/entity property, integer (0-16). Indicates the maximum number of MIDI channels on which a device may simultaneously receive MIDI Channel Messages. Common values are 0 (devices which only respond to System Messages), 1 (non-multitimbral devices), and 16 (fully multitimbral devices). Other values are possible, for example devices which are multitimbral but have fewer than 16 "parts".

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyMaxSysExSpeed

      kMIDIPropertyMaxSysExSpeed

      device/entity/endpoint property, integer

      Set by the owning driver; should not be touched by other clients. The value is the maximum rate, in bytes/second, at which sysex messages may be sent reliably to this object. (The default value is 3125, as with MIDI 1.0)

      Available in iOS 4.2 and later.

    • kMIDIPropertyMaxTransmitChannels

      kMIDIPropertyMaxTransmitChannels

      device/entity property, integer (0/1). Indicates the maximum number of MIDI channels on which a device may simultaneously transmit MIDI Channel Messages. Common values are 0, 1 and 16.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyModel

      kMIDIPropertyModel

      device/endpoint property, string

      Drivers should set this property on their devices.

      Setup editors may allow the user to set this property on external devices.

      Creators of virtual endpoints may set this property on their endpoints.

      Available in iOS 4.2 and later.

    • kMIDIPropertyName

      kMIDIPropertyName

      device/entity/endpoint property, string

      Devices, entities, and endpoints may all have names. The recommended way to display an endpoint's name is to ask for the endpoint name, and display only that name if it is unique. If it is non-unique, prepend the device name.

      A setup editor may allow the user to set the names of both driver-owned and external devices.

      Available in iOS 4.2 and later.

    • kMIDIPropertyNameConfiguration

      kMIDIPropertyNameConfiguration

      device/entity/endpoint property, CFDictionary

      This specifies the device's current patch, note and control name values using the MIDINameDocument XML format. This specification requires the use of higher-level, OS-specific constructs outside of the specification, to fully define the current names for a device.

      The MIDINameConfiguration property is implemented as a CFDictionary:

      key "master" maps to a CFDataRef containing an AliasHandle referring to the device's master name document.

      key "banks" maps to a CFDictionaryRef. This dictionary's keys are CFStringRef names of patchBank elements in the master document, and its values are each a CFDictionaryRef: key "file" maps to a CFDataRef containing an AliasHandle to a document containing patches that override those in the master document, and key "patchNameList" maps to a CFStringRef which is the name of the patchNameList element in the overriding document.

      key "currentChannelNameSets" maps to a 16-element CFArrayRef, each element of which is a CFStringRef of the name of the current mode for each of the 16 MIDI channels.

      key "currentDeviceMode" maps to a CFStringRef containing the name of the device's mode.

      Clients setting this property must take particular care to preserve dictionary values other than the ones they are interested in changing, and to properly structure the dictionary.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyOffline

      kMIDIPropertyOffline

      device/entity/endpoint property, integer

      1 = device is offline (is temporarily absent), 0 = present. Set by the owning driver, on the device; should not be touched by other clients. Property is inherited from the device by its entities and endpoints. New for CoreMIDI 1.1 (Mac OS X 10.1)

      Available in iOS 4.2 and later.

    • kMIDIPropertyPanDisruptsStereo

      kMIDIPropertyPanDisruptsStereo

      device/entity property, integer (0/1). Indicates whether the MIDI pan messages (control 10), when sent to the device or entity, cause undesirable effects when playing stereo sounds (e.g. converting the signal to mono). New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyPrivate

      kMIDIPropertyPrivate

      device/entity/endpoint property, integer

      1 = endpoint is private, hidden from other clients. May be set on a device or entity, but they will still appear in the API; only affects whether the owned endpoints are hidden. New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyReceiveChannels

      kMIDIPropertyReceiveChannels

      endpoint property, integer

      The value is a bitmap of channels on which the object receives: 1=ch 1, 2=ch 2, 4=ch 3 ... 0x8000=ch 16.

      Drivers may set this property on their entities or endpoints.

      Setup editors may allow the user to set this property on external endpoints.

      Virtual destination may set this property on their endpoints.

      Available in iOS 4.2 and later.

    • kMIDIPropertyReceivesBankSelectLSB

      kMIDIPropertyReceivesBankSelectLSB

      device/entity property, integer (0/1). Indicates whether the device or entity responds to MIDI bank select LSB messages (control 32).

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyReceivesBankSelectMSB

      kMIDIPropertyReceivesBankSelectMSB

      device/entity property, integer (0/1). Indicates whether the device or entity responds to MIDI bank select MSB messages (control 0).

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyReceivesClock

      kMIDIPropertyReceivesClock

      device/entity property, integer (0/1). Indicates whether the device or entity responds to MIDI beat clock messages.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyReceivesMTC

      kMIDIPropertyReceivesMTC

      device/entity property, integer (0/1). Indicates whether the device or entity responds to MIDI Time Code messages.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyReceivesNotes

      kMIDIPropertyReceivesNotes

      device/entity property, integer (0/1). Indicates whether the device or entity responds to MIDI Note On messages.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyReceivesProgramChanges

      kMIDIPropertyReceivesProgramChanges

      device/entity property, integer (0/1). Indicates whether the device or entity responds to MIDI program change messages.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertySingleRealtimeEntity

      kMIDIPropertySingleRealtimeEntity

      device property, integer

      Some MIDI interfaces cannot route MIDI realtime messages to individual outputs; they are broadcast. On such devices the inverse is usually also true -- incoming realtime messages cannot be identified as originating from any particular source.

      When this property is set on a driver device, it signifies the 0-based index of the entity on which incoming realtime messages from the device will appear to have originated from.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertySupportsGeneralMIDI

      kMIDIPropertySupportsGeneralMIDI

      device/entity property, integer (0/1). Indicates whether the device or entity implements the General MIDI specification.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertySupportsMMC

      kMIDIPropertySupportsMMC

      device/entity property, integer (0/1). Indicates whether the device or entity implements the MIDI Machine Control portion of the MIDI specification.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertySupportsShowControl

      kMIDIPropertySupportsShowControl

      device/entity property, integer (0/1). Indicates whether the device implements the MIDI Show Control specification.

      New for CoreMIDI 1.5.

      Available in iOS 4.2 and later.

    • kMIDIPropertyTransmitChannels

      kMIDIPropertyTransmitChannels

      endpoint property, integer

      The value is a bitmap of channels on which the object transmits: 1=ch 1, 2=ch 2, 4=ch 3 ... 0x8000=ch 16.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyTransmitsBankSelectLSB

      kMIDIPropertyTransmitsBankSelectLSB

      device/entity property, integer (0/1). Indicates whether the device or entity transmits MIDI bank select LSB messages (control 32).

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyTransmitsBankSelectMSB

      kMIDIPropertyTransmitsBankSelectMSB

      device/entity property, integer (0/1). Indicates whether the device or entity transmits MIDI bank select MSB messages (control 0).

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyTransmitsClock

      kMIDIPropertyTransmitsClock

      device/entity property, integer (0/1). Indicates whether the device or entity transmits MIDI beat clock messages.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyTransmitsMTC

      kMIDIPropertyTransmitsMTC

      device/entity property, integer (0/1). Indicates whether the device or entity transmits MIDI Time Code messages.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyTransmitsNotes

      kMIDIPropertyTransmitsNotes

      device/entity property, integer (0/1). Indicates whether the device or entity transmits MIDI note messages.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyTransmitsProgramChanges

      kMIDIPropertyTransmitsProgramChanges

      device/entity property, integer (0/1). Indicates whether the device or entity transmits MIDI program change messages.

      New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIPropertyUniqueID

      kMIDIPropertyUniqueID

      devices, entities, endpoints all have unique ID's, integer

      The system assigns unique ID's to all objects. Creators of virtual endpoints may set this property on their endpoints, though doing so may fail if the chosen ID is not unique.

      Available in iOS 4.2 and later.

  • The error constants unique to Core MIDI.

    Declaration

    Swift

    var kMIDIInvalidClient: Int { get } var kMIDIInvalidPort: Int { get } var kMIDIWrongEndpointType: Int { get } var kMIDINoConnection: Int { get } var kMIDIUnknownEndpoint: Int { get } var kMIDIUnknownProperty: Int { get } var kMIDIWrongPropertyType: Int { get } var kMIDINoCurrentSetup: Int { get } var kMIDIMessageSendErr: Int { get } var kMIDIServerStartErr: Int { get } var kMIDISetupFormatErr: Int { get } var kMIDIWrongThread: Int { get } var kMIDIObjectNotFound: Int { get } var kMIDIIDNotUnique: Int { get }

    Objective-C

    enum { kMIDIInvalidClient = -10830, kMIDIInvalidPort = -10831, kMIDIWrongEndpointType = -10832, kMIDINoConnection = -10833, kMIDIUnknownEndpoint = -10834, kMIDIUnknownProperty = -10835, kMIDIWrongPropertyType = -10836, kMIDINoCurrentSetup = -10837, kMIDIMessageSendErr = -10838, kMIDIServerStartErr = -10839, kMIDISetupFormatErr = -10840, kMIDIWrongThread = -10841, kMIDIObjectNotFound = -10842, kMIDIIDNotUnique = -10843 };

    Constants

    • kMIDIInvalidClient

      kMIDIInvalidClient

      An invalid MIDIClientRef was passed.

      Available in iOS 4.2 and later.

    • kMIDIInvalidPort

      kMIDIInvalidPort

      An invalid MIDIPortRef was passed.

      Available in iOS 4.2 and later.

    • kMIDIWrongEndpointType

      kMIDIWrongEndpointType

      A source endpoint was passed to a function expecting a destination, or vice versa.

      Available in iOS 4.2 and later.

    • kMIDINoConnection

      kMIDINoConnection

      Attempt to close a non-existant connection.

      Available in iOS 4.2 and later.

    • kMIDIUnknownEndpoint

      kMIDIUnknownEndpoint

      An invalid MIDIEndpointRef was passed.

      Available in iOS 4.2 and later.

    • kMIDIUnknownProperty

      kMIDIUnknownProperty

      Attempt to query a property not set on the object.

      Available in iOS 4.2 and later.

    • kMIDIWrongPropertyType

      kMIDIWrongPropertyType

      Attempt to set a property with a value not of the correct type.

      Available in iOS 4.2 and later.

    • kMIDINoCurrentSetup

      kMIDINoCurrentSetup

      Internal error; there is no current MIDI setup object.

      Available in iOS 4.2 and later.

    • kMIDIMessageSendErr

      kMIDIMessageSendErr

      Communication with MIDIServer failed.

      Available in iOS 4.2 and later.

    • kMIDIServerStartErr

      kMIDIServerStartErr

      Unable to start MIDIServer.

      Available in iOS 4.2 and later.

    • kMIDISetupFormatErr

      kMIDISetupFormatErr

      Unable to read the saved state.

      Available in iOS 4.2 and later.

    • kMIDIWrongThread

      kMIDIWrongThread

      A driver is calling a non-I/O function in the server from a thread other than the server's main thread.

      Available in iOS 4.2 and later.

    • kMIDIObjectNotFound

      kMIDIObjectNotFound

      The requested object does not exist.

      Available in iOS 4.2 and later.

    • kMIDIIDNotUnique

      kMIDIIDNotUnique

      Attempt to set a non-unique kMIDIPropertyUniqueID on an object.

      Available in iOS 4.2 and later.

    Discussion

    These are the error constants that are unique to Core MIDI. Note that Core MIDI functions may return other codes that are not listed here.

  • Signifies the type of a MIDINotification.

    Declaration

    Swift

    typealias MIDINotificationMessageID = Int32

    Objective-C

    enum { kMIDIMsgSetupChanged = 1, kMIDIMsgObjectAdded = 2, kMIDIMsgObjectRemoved = 3, kMIDIMsgPropertyChanged = 4, kMIDIMsgThruConnectionsChanged = 5, kMIDIMsgSerialPortOwnerChanged = 6, kMIDIMsgIOError = 7 }; typedef SInt32 MIDINotificationMessageID;

    Constants

    • kMIDIMsgSetupChanged

      kMIDIMsgSetupChanged

      Some aspect of the current MIDISetup has changed. No data. Should ignore this message if messages 2-6 are handled.

      Available in iOS 4.2 and later.

    • kMIDIMsgObjectAdded

      kMIDIMsgObjectAdded

      A device, entity or endpoint was added. Structure is MIDIObjectAddRemoveNotification. New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIMsgObjectRemoved

      kMIDIMsgObjectRemoved

      A device, entity or endpoint was removed. Structure is MIDIObjectAddRemoveNotification. New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIMsgPropertyChanged

      kMIDIMsgPropertyChanged

      An object's property was changed. Structure is MIDIObjectPropertyChangeNotification. New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIMsgThruConnectionsChanged

      kMIDIMsgThruConnectionsChanged

      A persistent MIDI Thru connection was created or destroyed. No data. New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIMsgSerialPortOwnerChanged

      kMIDIMsgSerialPortOwnerChanged

      A persistent MIDI Thru connection was created or destroyed. No data. New for CoreMIDI 1.3.

      Available in iOS 4.2 and later.

    • kMIDIMsgIOError

      kMIDIMsgIOError

      A driver I/O error occurred.

      Available in iOS 4.2 and later.

    Discussion

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Indicates the type of a MIDI object.

    Declaration

    Swift

    typealias MIDIObjectType = Int32

    Objective-C

    enum { kMIDIObjectType_Other = -1, kMIDIObjectType_Device = 0, kMIDIObjectType_Entity = 1, kMIDIObjectType_Source = 2, kMIDIObjectType_Destination = 3, kMIDIObjectType_ExternalMask = 0x10, kMIDIObjectType_ExternalDevice = kMIDIObjectType_ExternalMask | kMIDIObjectType_Device, kMIDIObjectType_ExternalEntity = kMIDIObjectType_ExternalMask | kMIDIObjectType_Entity, kMIDIObjectType_ExternalSource = kMIDIObjectType_ExternalMask | kMIDIObjectType_Source, kMIDIObjectType_ExternalDestination = kMIDIObjectType_ExternalMask | kMIDIObjectType_Destination }; typedef SInt32 MIDIObjectType;

    Constants

    • kMIDIObjectType_Other

      kMIDIObjectType_Other

      An unspecified MIDI object type.

      Available in iOS 4.2 and later.

    • kMIDIObjectType_Device

      kMIDIObjectType_Device

      A MIDI device.

      Available in iOS 4.2 and later.

    • kMIDIObjectType_Entity

      kMIDIObjectType_Entity

      A MIDI entity.

      Available in iOS 4.2 and later.

    • kMIDIObjectType_Source

      kMIDIObjectType_Source

      A MIDI source.

      Available in iOS 4.2 and later.

    • kMIDIObjectType_Destination

      kMIDIObjectType_Destination

      A MIDI destination.

      Available in iOS 4.2 and later.

    • kMIDIObjectType_ExternalMask

      kMIDIObjectType_ExternalMask

      Bit mask for indicating that a device is external.

      Available in iOS 4.2 and later.

    • kMIDIObjectType_ExternalDevice

      kMIDIObjectType_ExternalDevice

      An external MIDI device.

      Available in iOS 4.2 and later.

    • kMIDIObjectType_ExternalEntity

      kMIDIObjectType_ExternalEntity

      An external MIDI entity.

      Available in iOS 4.2 and later.

    • kMIDIObjectType_ExternalSource

      kMIDIObjectType_ExternalSource

      An external MIDI source.

      Available in iOS 4.2 and later.

    • kMIDIObjectType_ExternalDestination

      kMIDIObjectType_ExternalDestination

      An external MIDI destination.

      Available in iOS 4.2 and later.

    Discussion

    Signifies the real type of a MIDIObjectRef instance.

    Import Statement

    Objective-C

    @import CoreMIDI;

    Swift

    import CoreMIDI

    Availability

    Available in iOS 4.2 and later.

  • Indicates that the MIDI unique ID is not valid.

    Declaration

    Swift

    var kMIDIInvalidUniqueID: Int { get }

    Objective-C

    enum { kMIDIInvalidUniqueID = 0 };

    Constants

    • kMIDIInvalidUniqueID

      kMIDIInvalidUniqueID

      The MIDI unique ID is not valid.

      Available in iOS 4.2 and later.