         case .songPosition:
             internalData[1] = byte1.lower7bits()
             internalData[2] = byte2.lower7bits()
-            length = 3
+            setLength(3)
         case .songSelect:
             internalData[1] = byte1.lower7bits()
-            length = 2
+            setLength(2)
         default:
-            length = 1
+            setLength(1)
         }
         if let existingLength = length {
             internalData = Array(internalData.prefix(Int(existingLength)))

        internalData[1] = byte1.lower7bits()
        internalData[2] = byte2.lower7bits()

        length = 3
        internalData = Array(internalData[0..<3])

    }


    static public func midiEventsFrom(packetListPointer: UnsafePointer< MIDIPacketList>) -> [AKMIDIEvent] {
        return packetListPointer.pointee.map { AKMIDIEvent(packet: $0) }
    }
    
    private mutating func setLength(_ newLength:Int){
        setLength(MIDIByte(newLength))
    }
    private mutating func setLength(_ newLength:MIDIByte){
        length = newLength
        internalData = Array(internalData[0..<Int(length!)])
    }
}
