AKMIDIInstrument

open class AKMIDIInstrument: AKPolyphonicNode, AKMIDIListener

A version of AKInstrument specifically targeted to instruments that should be triggerable via MIDI or sequenced with the sequencer.

  • MIDI Input

    Declaration

    Swift

    open var midiIn = MIDIEndpointRef()
  • Name of the instrument

    Declaration

    Swift

    open var name = "AKMIDIInstrument"
  • Enable MIDI input from a given MIDI client This is not in the init function because it must be called AFTER you start audiokit

    • Parameters:
      • midiClient: A refernce to the midi client
      • name: Name to connect with

    Declaration

    Swift

    open func enableMIDI(_ midiClient: MIDIClientRef, name: String)

    Parameters

    midiClient

    A refernce to the midi client

    name

    Name to connect with

  • Handle MIDI commands that come in externally

    • Parameters:
      • noteNumber: MIDI Note number
      • velocity: MIDI velocity
      • channel: MIDI channel

    Declaration

    Swift

    open func receivedMIDINoteOn(_ noteNumber: MIDINoteNumber,
                                     velocity: MIDIVelocity,
                                     channel: MIDIChannel)

    Parameters

    noteNumber

    MIDI Note number

    velocity

    MIDI velocity

    channel

    MIDI channel

  • Handle MIDI commands that come in externally

    • Parameters:
      • noteNumber: MIDI Note number
      • velocity: MIDI velocity
      • channel: MIDI channel

    Declaration

    Swift

    open func receivedMIDINoteOff(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel)

    Parameters

    noteNumber

    MIDI Note number

    velocity

    MIDI velocity

    channel

    MIDI channel

  • Start a note

    • Parameters:
      • noteNumber: Note number to play
      • velocity: Velocity at which to play the note (0 - 127)
      • channel: Channel on which to play the note

    Declaration

    Swift

    open func start(noteNumber: MIDINoteNumber,
                        velocity: MIDIVelocity,
                        channel: MIDIChannel)

    Parameters

    noteNumber

    Note number to play

    velocity

    Velocity at which to play the note (0 - 127)

    channel

    Channel on which to play the note

  • Stop a note

    • Parameters:
      • noteNumber: Note number to stop
      • channel: Channel on which to stop the note

    Declaration

    Swift

    open func stop(noteNumber: MIDINoteNumber, channel: MIDIChannel)

    Parameters

    noteNumber

    Note number to stop

    channel

    Channel on which to stop the note