Core MIDI

RSS for tag

Communicate with MIDI (Musical Instrument Digital Interface) devices using Core MIDI.

Core MIDI Documentation

Posts under Core MIDI tag

21 Posts
Sort by:
Post not yet marked as solved
2 Replies
666 Views
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: let numPackets = packetList.numPackets os_log(.info, log: log, "processPackets - %d", numPackets) var packet: MIDIPacket = packetList.packet for index in 0..<numPackets { &#9;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 { &#9;  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?
Posted
by