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"
  • Initialize the MIDI Instrument

    Declaration

    Swift

    public override init()
  • Enable MIDI input from a given MIDI client

    Declaration

    Swift

    open func enableMIDI(_ midiClient: MIDIClientRef = AKMIDI().client,
                             name: String = "Unnamed")

    Parameters

    midiClient

    A refernce to the midi client

    name

    Name to connect with

  • Handle MIDI commands that come in externally

    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

    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

    Declaration

    Swift

    @objc 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

    Declaration

    Swift

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

    Parameters

    noteNumber

    Note number to stop

    channel

    Channel on which to stop the note