AKMIDIListener not receiving SysEx

322 Views Asked by At

I am using AudioKit's AKMIDIListener protocol on a class to listen for MIDI messages. This is working fine for standard messages such as Note On, but SysEx messages are not coming through.

func receivedMIDINoteOn(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel) {
    NSLog("Note On \(noteNumber), \(velocity), \(channel)") // works perfectly
}
func receivedMIDISystemCommand(_ data: [MIDIByte]) {
    NSLog("SysEx \(data)") // never triggers

    // More code to handle the messages...
}

The SysEx messages are sent from external hardware or test software. I have used MIDI monitoring apps to make sure the messages are being sent correctly, yet in my app they are not triggering receivedMIDISystemCommand.

Are there any additional steps required to receive SysEx messages that I'm missing?

Thanks in advance for any clues.

1

There are 1 best solutions below

3
analogcode On BEST ANSWER

EDIT: Thanks for bringing this to our attention. The SysEx receiving issue has now been fixed in the develop branch of AudioKit: https://github.com/AudioKit/AudioKit/pull/1017

--

Instead of

NSLog("SysEx \(data)")

Have you tried?

if let sysExCommand = AKMIDISystemCommand(rawValue: data[0]) {
   print("MIDI System Command: \(sysExCommand)")
}

AKMIDISystemCommand will convert your SysEx data to something a bit more usable and is defined as follows:

public enum AKMIDISystemCommand: MIDIByte {
    /// Trivial Case of None
    case none = 0
    /// System Exclusive
    case sysex = 240
    /// Song Position
    case songPosition = 242
    /// Song Selection
    case songSelect = 243
    /// Request Tune
    case tuneRequest = 246
    /// End System Exclusive
    case sysexEnd = 247
    /// Clock
    case clock = 248
    /// Start
    case start = 250
    /// Continue
    case `continue` = 251
    /// Stop
    case stop = 252
    /// Active Sensing
    case activeSensing = 254
    /// System Reset
    case sysReset = 255
}

-- matthew @ audiokit