data1 = c; } else if (runningStatus >= ShortMessage.PROGRAM_CHANGE && runningStatus < ShortMessage.PITCH_BEND) {
buf[1] = (byte) c; } else if (runningStatus >= ShortMessage.PROGRAM_CHANGE && runningStatus < ShortMessage.PITCH_BEND) {
		private void addToList(int c) throws InvalidMidiDataException {		    MidiMessage msg;		    if ((c & 0x80) == 0x80) {			// status byte			if ((c & 0xf8) == 0xf8 // System Real Time Message			    || c == ShortMessage.TUNE_REQUEST) {			    // 0 byte message			    msg = (MidiMessage) new ShortMessage();			    ((ShortMessage) msg).setMessage(c);			    list.add(msg);			} else if (c == SysexMessage.SYSTEM_EXCLUSIVE) {			    buf[0] = (byte) c;			    size = 1;			} else if (c == ShortMessage.END_OF_EXCLUSIVE				   && 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);			}			if ((c & 0xf8) != 0xf8) {			    // System Real Time Message			    // should not affect runningStatus nor thirdByte			    runningStatus = c;			    thirdByte = false;			}		    } else {			// data byte			if (thirdByte) {			    thirdByte = false;			    msg = (MidiMessage) new ShortMessage();			    ((ShortMessage) msg).setMessage(runningStatus, data1, c);			    list.add(msg);			} else if (runningStatus == 0) {			    ;	// ignore			} else if (runningStatus < ShortMessage.PROGRAM_CHANGE				   || (runningStatus >= ShortMessage.PITCH_BEND				       && runningStatus < SysexMessage.SYSTEM_EXCLUSIVE)) {			    // 2 byte message			    thirdByte = true;			    data1 = c;			} else if (runningStatus == ShortMessage.SONG_POSITION_POINTER) {			    // 2 byte message			    runningStatus = 0;			    thirdByte = true;			    data1 = c;			} else if (runningStatus >= ShortMessage.PROGRAM_CHANGE				   && runningStatus < ShortMessage.PITCH_BEND) {			    // 1 byte message			    msg = (MidiMessage) new ShortMessage();			    ((ShortMessage) msg).setMessage(runningStatus, data1, 0);			    list.add(msg);			} else if (runningStatus == ShortMessage.MIDI_TIME_CODE				   || runningStatus == ShortMessage.SONG_SELECT) {			    // 1 byte message			    runningStatus = 0;			    msg = (MidiMessage) new ShortMessage();			    ((ShortMessage) msg).setMessage(runningStatus, data1, 0);			    list.add(msg);			} else if (runningStatus == SysexMessage.SYSTEM_EXCLUSIVE) {			    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;			    }			} else {			    // f4 (undef), f5 (undef), f6 (Tune Request), f7 (EOX)			    runningStatus = 0;			    // ignore Status			}		    }		}