                         AKLog("Problem with raw midi channel message")
                         return
                 }
-                let status = statusData >> 4
-                switch Int(status) {
-                case AKMIDIStatus.programChange.rawValue:
-                    print("MIDI Program Change @ \(event.time) - program: \(data1)")
-                default:
-                    print("MIDI Channel Message @ \(event.time) - data1: \(data1) - data2: \(data2) - status: \(status)")
+                if let status = statusData.status,
+                    let channel = statusData.channel {
+                    switch status {
+                    case .programChange:
+                        print("MIDI Program Change @ \(event.time) - program: \(data1) - channel: \(channel)")
+                    default:
+                        print("MIDI Channel Message @ \(event.time) - data1: \(data1) - data2: \(data2) - status: \(status)")
+                    }
                 }
             default:
                 print("MIDI Event @ \(event.time)")


public struct MIDIProgramChangeEvent {
    var time: MusicTimeStamp
    var number: UInt8
}

                if event.type == kMusicEventType_MIDIChannelMessage {
                    let data = UnsafePointer<MIDIChannelMessage>(event.data?.assumingMemoryBound(to: MIDIChannelMessage.self))
                    guard let data1 = data?.pointee.data1,
                        let statusData: MIDIByte = data?.pointee.status else {
                            break
                    }
                    if let status = statusData.status,
                        let channel = statusData.channel {
                        if status == .programChange {
                            let pgmEvent = MIDIProgramChangeEvent(time: event.time, channel: channel, number: data1)
                            pgmEvents.append(pgmEvent)
                        }
                    }
                }
            }
