While vigorously testing out my iOS app with a MIDI controller keyboard, I sometimes generate CoreMIDI input that is clearly garbage. Here is the code I use to iterate over the MIDIPacketList:
If I pound away on the keys and do a lot of pitch bends and mod wheel spins, I can sometimes get what appears to be garbage, with packets of either 0 or 22624 bytes (which is curiously 0x6800 hex). As above, I currently stop processing the MIDIPacketList when this happens, but that is clearly not a great solution. Anyone else encounter something like this?
Code Block let numPackets = packetList.numPackets os_log(.info, log: log, "processPackets - %d", numPackets) var packet: MIDIPacket = packetList.packet for index in 0..<numPackets { os_log(.info, log: log, "packet %d - %d bytes", index, packet.length) // Filter out garbage (zero or really big sizes of 26624) if packet.length == 0 || packet.length > 30 { os_log(.error, log: log, "suspect packet size %d", packet.length) break } processPacket(packet, controller) packet = MIDIPacketNext(&packet).pointee }
If I pound away on the keys and do a lot of pitch bends and mod wheel spins, I can sometimes get what appears to be garbage, with packets of either 0 or 22624 bytes (which is curiously 0x6800 hex). As above, I currently stop processing the MIDIPacketList when this happens, but that is clearly not a great solution. Anyone else encounter something like this?