public Patch[] extractPatch(Patch p) { // get all bytes from the (64 * ((32*pads)+settings)) + chain + system byte[] msgs = p.getByteArray(); // create a Patch[] pa to hold the created Patches (2*Single and 64*Bank) Patch[] pa = new Patch[66]; // do 64 times this: for (int i = 0; i < NR_OF_PATCHBANKS; i++) { // create a new byte array for a CompletePatch byte[] ptchbnk = new byte[PATCHBANKSIZE]; // copy the current 915 bytes to this byte array System.arraycopy(msgs, i * PATCHBANKSIZE, ptchbnk, 0, PATCHBANKSIZE); // create a new CompletePatch with these bytes and put it in pa at the current position pa[i] = new Patch(ptchbnk, patch2Driver); // increase i with 1 or go on if i is already 63 } // all CompletePatches are created // now create the chain patch byte array chn byte[] chn = new byte[CHAINSIZE]; // copy the chain bytes into chn System.arraycopy(msgs, NR_OF_PATCHBANKS * PATCHBANKSIZE, chn, 0, CHAINSIZE); // create a new chain patch with these bytes and put it in the patcharray pa[64] = new Patch(chn, chainDriver); // now create the system byte array sstm byte[] sstm = new byte[SYSTEMSIZE]; // copy the system bytes into sstm System.arraycopy(msgs, (NR_OF_PATCHBANKS * PATCHBANKSIZE) + CHAINSIZE, sstm, 0, SYSTEMSIZE); // create a new system patch with these bytes and put it in the patcharray pa[65] = new Patch(sstm, systemDriver); // return the full array of (64*CompletePatch)+Chain+System return pa; }