sysex from AudioKit's receivedMIDISystemCommand

224 Views Asked by At

I am very new to Swift and struggling so please go easy. I am building a macOS project using Swift 4 in XCode 10.1

I am receiving a sysex message from a device using the following code which I got from the MIDIUtility example project supplied with AudioKit:

func receivedMIDISystemCommand(_ data: [MIDIByte]) {
    if let command = AKMIDISystemCommand(rawValue: data[0]) {
        var newString = "MIDI System Command: \(command) \n"
        var hexArray = [UInt8]()
        for bit in data {
            hexArray.append(bit)    //this requires 'public typealias MIDIByte = UInt8'
            newString.append(String("\(bit) "))
        }
        updateText("\(newString) \n")
        updateData(hexArray)
    }
    updateText("received \(data.count) bytes of data \n\n")
}

The sysex I am receiving is very different than what I get when using SysEx Librarian or MIDI Monitor to receive the same sysEx. Both of these apps receive 6 packets of 32,110,110,110,110, and 110 bytes. This is what I expect to get from my MIDI device. My code gets 6 packets of 520,1300,20,1538,1294 and 1544 bytes. It looks like the data I want is in these packets, but it is spit up by a bunch of 0's.

data as received in MIDI Monitor or SysEx Librarian: some of the data as received by my code

Why is my code receiving so much extra data? Is there a way to filter out the unwanted data or will I need to figure out how to use something other that AudioKit for my project?

0

There are 0 best solutions below