AKMIDI

open class AKMIDI

MIDI input and output handler

You add MIDI listeners like this:

var midi = AudioKit.midi
midi.openInput()
midi.addListener(someClass)

…where someClass conforms to the AKMIDIListener protocol

You then implement the methods you need from AKMIDIListener and use the data how you need.

  • MIDI Client Reference

    Declaration

    Swift

    open var client: MIDIClientRef
  • Virtual MIDI Input destination

    Declaration

    Swift

    open var virtualInput: MIDIPortRef
  • MIDI Out Port Reference

    Declaration

    Swift

    public var outputPort: MIDIPortRef
  • Virtual MIDI output

    Declaration

    Swift

    open var virtualOutput: MIDIPortRef
  • Array of MIDI Endpoints

    Declaration

    Swift

    open var endpoints: [MIDIUniqueID : MIDIEndpointRef]
  • Initialize the AKMIDI system

    Declaration

    Swift

    @objc
    public init()
  • Array of input source unique ids

    Declaration

    Swift

    public var inputUIDs: [MIDIUniqueID] { get }
  • Array of input source names

    Declaration

    Swift

    public var inputNames: [String] { get }
  • Lookup a input name from its unique id

    Declaration

    Swift

    public func inputName(for inputUid: MIDIUniqueID) -> String?

    Parameters

    forUid

    unique id for a input

    Return Value

    name of input or nil

  • Look up the unique id for a input index

    Declaration

    Swift

    public func uidForInputAtIndex(_ inputIndex: Int = 0) -> MIDIUniqueID

    Parameters

    inputIndex

    index of destination

    Return Value

    unique identifier for the port

  • Open a MIDI Input port by name

    Declaration

    Swift

    public func openInput(name: String = "")

    Parameters

    inputIndex

    Index of source port

  • Open a MIDI Input port by index

    Declaration

    Swift

    public func openInput(index inputIndex: Int)

    Parameters

    inputIndex

    Index of source port

  • Open a MIDI Input port

    Declaration

    Swift

    public func openInput(uid inputUID: MIDIUniqueID)

    Parameters

    inputUID

    Unique identifier for a MIDI Input

  • Open a MIDI Input port by name

    Declaration

    Swift

    @available(*, deprecated, message: "Try to not use names any more because they are not unique across devices")
    public func closeInput(name: String)

    Parameters

    inputIndex

    Index of source port

  • Declaration

    Swift

    public func closeInput()
  • Open a MIDI Input port by index

    Declaration

    Swift

    public func closeInput(index inputIndex: Int)

    Parameters

    inputIndex

    Index of source port

  • Close a MIDI Input port

    Declaration

    Swift

    public func closeInput(uid inputUID: MIDIUniqueID)

    Parameters

    inputName

    Unique id of the MIDI Input

  • Close all MIDI Input ports

    Declaration

    Swift

    public func closeAllInputs()
  • Array of destination unique ids

    Declaration

    Swift

    public var destinationUIDs: [MIDIUniqueID] { get }
  • Array of destination names

    Declaration

    Swift

    public var destinationNames: [String] { get }
  • Lookup a destination name from its unique id

    Declaration

    Swift

    public func destinationName(for destUid: MIDIUniqueID) -> String

    Parameters

    forUid

    unique id for a destination

    Return Value

    name of destination or Unknown

  • Look up the unique id for a destination index

    Declaration

    Swift

    public func uidForDestinationAtIndex(_ outputIndex: Int = 0) -> MIDIUniqueID

    Parameters

    outputIndex

    index of destination

    Return Value

    unique identifier for the port

  • Open a MIDI Output Port by name

    Declaration

    Swift

    @available(*, deprecated, message: "Try to not use names any more because they are not unique across devices")
    public func openOutput(name: String)

    Parameters

    name

    String containing the name of the MIDI Output

  • Handle the acceptable default case of no parameter without causing a deprecation warning

    Declaration

    Swift

    public func openOutput()
  • Open a MIDI Output Port by index

    Declaration

    Swift

    public func openOutput(index outputIndex: Int)

    Parameters

    outputIndex

    Index of destination endpoint

  • Open a MIDI Output Port

    Declaration

    Swift

    public func openOutput(uid outputUid: MIDIUniqueID)

    Parameters

    outputUid

    Unique id of the MIDI Output

  • Close a MIDI Output port by name

    Declaration

    Swift

    public func closeOutput(name: String = "")

    Parameters

    name

    Name of port to close.

  • Close a MIDI Output port by index

    Declaration

    Swift

    public func closeOutput(index outputIndex: Int)

    Parameters

    index

    Index of destination port name

  • Close a MIDI Output port

    Declaration

    Swift

    public func closeOutput(uid outputUid: MIDIUniqueID)

    Parameters

    inputName

    Unique id of the MIDI Output

  • Send Message with data

    Declaration

    Swift

    public func sendMessage(_ data: [MIDIByte], offset: MIDITimeStamp = 0)
  • Clear MIDI destinations

    Declaration

    Swift

    public func clearEndpoints()
  • Send Messsage from MIDI event data

    Declaration

    Swift

    public func sendEvent(_ event: AKMIDIEvent)
  • Send a Note On Message

    Declaration

    Swift

    public func sendNoteOnMessage(noteNumber: MIDINoteNumber,
                                  velocity: MIDIVelocity,
                                  channel: MIDIChannel = 0)
  • Send a Note Off Message

    Declaration

    Swift

    public func sendNoteOffMessage(noteNumber: MIDINoteNumber,
                                   velocity: MIDIVelocity,
                                   channel: MIDIChannel = 0)
  • Send a Continuous Controller message

    Declaration

    Swift

    public func sendControllerMessage(_ control: MIDIByte, value: MIDIByte, channel: MIDIChannel = 0)
  • Send a pitch bend message.

    Declaration

    Swift

    public func sendPitchBendMessage(value: UInt16, channel: MIDIChannel = 0)

    Parameters

    value

    Value of pitch shifting between 0 and 16383. Send 8192 for no pitch bending.

    channel

    Channel you want to send pitch bend message. Defaults 0.

  • Create set of virtual input and output MIDI ports

    Declaration

    Swift

    open func createVirtualPorts(_ uniqueID: Int32 = 2_000_000, name: String? = nil)
  • Create a virtual MIDI input port

    Declaration

    Swift

    open func createVirtualInputPort(_ uniqueID: Int32 = 2_000_000, name: String? = nil)
  • Create a virtual MIDI output port

    Declaration

    Swift

    open func createVirtualOutputPort(_ uniqueID: Int32 = 2_000_001, name: String? = nil)
  • Discard all virtual ports

    Declaration

    Swift

    open func destroyVirtualPorts()
  • Closes the virtual input port, if created one already.

    Declaration

    Swift

    @discardableResult
    open func destroyVirtualInputPort() -> Bool

    Return Value

    Returns true if virtual input closed.

  • Closes the virtual output port, if created one already.

    Declaration

    Swift

    @discardableResult
    open func destroyVirtualOutputPort() -> Bool

    Return Value

    Returns true if virtual output closed.