runningStatus = c;
		private void addToList(int c) throws InvalidMidiDataException {		    MidiMessage msg;		    if ((c & ~0xff) != 0)			throw new InvalidMidiDataException();		    if ((c & 0x80) == 0x80) {			// status byte			if ((c & 0xf8) == 0xf8) { // System Real Time Message			    // 0 byte message			    msg = (MidiMessage) new ShortMessage();			    ((ShortMessage) msg).setMessage(c);			    list.add(msg);			} else {			    thirdByte = false;			    runningStatus = c;			    switch (c) {			    case ShortMessage.END_OF_EXCLUSIVE:				if (runningStatus == SysexMessage.SYSTEM_EXCLUSIVE) {				    byte[] d = new byte[size + 1];				    System.arraycopy(buf, 0, d, 0, size);				    d[size++] = (byte) c;				    msg = (MidiMessage) new SysexMessage();				    ((SysexMessage) msg).setMessage(d, size);				    list.add(msg);				}				break;			    case ShortMessage.TUNE_REQUEST: // 0xf6				// 0 byte message				msg = (MidiMessage) new ShortMessage();				((ShortMessage) msg).setMessage(c);				list.add(msg);				break;			    case SysexMessage.SYSTEM_EXCLUSIVE:				size = 1;				// FALLTHROUGH			    default:				buf[0] = (byte) c;			    }			}		    } else {			// data byte			if (thirdByte) {			    thirdByte = false;			    msg = (MidiMessage) new ShortMessage();			    ((ShortMessage) msg).setMessage((int) (buf[0] & 0xff),							    (int) (buf[1] & 0xff), c);			    list.add(msg);			} else {			    switch (runningStatus < 0xf0 ? runningStatus & 0xf0 : runningStatus) {			    case ShortMessage.SONG_POSITION_POINTER: // 0xf2				// 2 byte message				runningStatus = 0;				// FALLTHROUGH			    case ShortMessage.NOTE_OFF:		// 0x8n			    case ShortMessage.NOTE_ON:		// 0x9n			    case ShortMessage.POLY_PRESSURE:	// 0xAn			    case ShortMessage.CONTROL_CHANGE:	// 0xBn			    case ShortMessage.PITCH_BEND:	// 0xEn				// 2 byte message				thirdByte = true;				buf[1] = (byte) c;				break;			    case ShortMessage.MIDI_TIME_CODE:	// 0xf1			    case ShortMessage.SONG_SELECT:	// 0xf3				// 1 byte message				runningStatus = 0;				// FALLTHROUGH			    case ShortMessage.PROGRAM_CHANGE:	// 0xCn			    case ShortMessage.CHANNEL_PRESSURE:	// 0xDn				// 1 byte message				msg = (MidiMessage) new ShortMessage();				((ShortMessage) msg).setMessage((int) (buf[0] & 0xff), c, 0);				list.add(msg);				break;			    case SysexMessage.SYSTEM_EXCLUSIVE:	// 0xf0				buf[size++] = (byte) c;				if (size == buf.length) {				    // Sysex data buffer is full				    byte[] d = new byte[size];				    System.arraycopy(buf, 0, d, 0, size);				    msg = (MidiMessage) new SysexMessage();				    ((SysexMessage) msg).setMessage(d, size);				    list.add(msg);				    // See SysexMessage document.				    buf[0] = (byte) SysexMessage.SPECIAL_SYSTEM_EXCLUSIVE;				    size = 1;				}				break;			    default: // 0, 0xf4 (undef), 0xf5 (undef), 0xf6 (Tune Request), 0xf7 (EOX)				runningStatus = 0;				// ignore data			    }			}		    }		}