AKMIDIListener not receiving SysEx
Asked Answered
J

1

8

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.

Jeep answered 31/7, 2017 at 10:28 Comment(0)
B
0

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

Becka answered 3/8, 2017 at 23:46 Comment(3)
I have written the code necessary to check for first byte being 0xF0 and handling all other bytes appropriately. Interestingly enough, the NSLog("SysEx \(data)") mentioned does not trigger at all. Nothing is being logged, suggesting the receivedMIDISystemCommand is never run. Thanks for the suggestion though, using AKMIDISystemCommand will definitely clean up my code a bit.Jeep
@Jeep - Thank you for bringing this to our attention. We are working on a fix.Becka
@oscar We just fixed this in this pull request, so its fixed on the develop branch and will be in the next release: github.com/AudioKit/AudioKit/pull/1017Cresol

© 2022 - 2024 — McMap. All rights reserved.