void storePatch (byte[] sysex, int offset, int patchNum) { int deviceID = getDeviceID(); int port = getPort();  int size; for (int i = 0; i < NUM_PKT; i++, offset += size) {  size = PKT_SIZE[i]; byte [] tmpSysex = new byte [size]; System.arraycopy(sysex, offset, tmpSysex, 0, size); Patch p = new Patch(tmpSysex, (Driver) null);  p.sysex[2] = (byte) (deviceID - 1);  p.sysex[6] = (byte) 0x41; p.sysex[7] = (byte) patchNum; p.sysex[8] = (byte) i; calculateChecksum(p, 6, size - 3, size - 2);  try {  send(p.sysex); } catch (Exception e) { ErrorMsg.reportStatus(e); } try { Thread.sleep(50); } catch (Exception e) { ErrorMsg.reportStatus(e); } }
public void storePatch (Patch p, int bankNum, int patchNum) {   storePatch(p.sysex, 0, patchNum);
    void storePatch (byte[] sysex, int offset, int patchNum) {	int deviceID = getDeviceID();	int port = getPort();	int size;	for (int i = 0; i < NUM_PKT; i++, offset += size) {	    // create a Patch data for each packet	    size = PKT_SIZE[i];	    byte [] tmpSysex = new byte [size];	    System.arraycopy(sysex, offset, tmpSysex, 0, size);	    Patch p = new Patch(tmpSysex, (Driver) null);	    p.sysex[2] = (byte) (deviceID - 1);	    // Drum kit : kk,  address 41 kk ii 00	    p.sysex[6] = (byte) 0x41;	    p.sysex[7] = (byte) patchNum;	    p.sysex[8] = (byte) i;	    calculateChecksum(p, 6, size - 3, size - 2);// 	    p.sysex[size - 2] = calcChkSum(tmpSysex, 6, size - 3);	    try {		//PatchEdit.MidiOut.writeLongMessage(port, p.sysex);		send(p.sysex);	    } catch (Exception e) {		ErrorMsg.reportStatus(e);	    }	    try {		Thread.sleep(50);	// wait at least 50 milliseconds.	    } catch (Exception e) {		ErrorMsg.reportStatus(e);	    }	}    }