public IPatch getPatch(IPatch bank, int patchNum)
public Patch getPatch(Patch bank, int patchNum)
  public IPatch getPatch(IPatch bank, int patchNum)  {      byte bankSysexNibbles[] = new byte[64];      byte bankSysex[] = new byte[32];      byte sysex[] = new byte[54];      sysex[0] = (byte)0xF0;      sysex[1] = (byte)0x41;      sysex[2] = (byte)0x35;      sysex[3] = (byte)0x00;      sysex[4] = (byte)0x23;      sysex[5] = (byte)0x20;      sysex[6] = (byte)0x01;      sysex[53] = (byte)0xF7;      int patchOffset = getPatchStart(patchNum);      System.arraycopy(((Patch)bank).sysex, patchOffset, bankSysexNibbles, 0, 64);      //   convert bank tone (31 bytes, lo/hi nibble) to single tone (46 bytes)      for (int i = 0; i < 32; i++)      {        bankSysex[i] = (byte)(bankSysexNibbles[i*2] | bankSysexNibbles[i*2+1] << 4);      }      // DCO ENV MODE      sysex[7] = (byte)((bankSysex[5] & 0x80) >> 6 | (bankSysex[6] & 0x80) >> 7);      // VCF ENV MODE      sysex[8] = (byte)((bankSysex[7] & 0x80) >> 6 | (bankSysex[8] & 0x80) >> 7);      // VCA ENV MODE      sysex[9] = (byte)((bankSysex[9] & 0x80) >> 6 | (bankSysex[10] & 0x80) >> 7);      // DCO WAVEFORM PULSE      sysex[10] = (byte)((bankSysex[17] & 0x80) >> 6 | (bankSysex[18] & 0x80) >> 7);      // DCO WAVEFORM SAWTOOTH      sysex[11] = (byte)((bankSysex[14] & 0x80) >> 5 | (bankSysex[15] & 0x80) >> 6 | (bankSysex[16] & 0x80) >> 7);      // DCO WAVEFORM SUB      sysex[12] = (byte)((bankSysex[11] & 0x80) >> 5 | (bankSysex[12] & 0x80) >> 6 | (bankSysex[13] & 0x80) >> 7);      // DCO RANGE      sysex[13] = (byte)((bankSysex[21] & 0x80) >> 6 | (bankSysex[22] & 0x80) >> 7);      // DCO SUB LEVEL      sysex[14] = (byte)((bankSysex[23] & 0x80) >> 6 | (bankSysex[24] & 0x80) >> 7);      // DCO NOISE LEVEL      sysex[15] = (byte)((bankSysex[25] & 0x80) >> 6 | (bankSysex[26] & 0x80) >> 7);      // HPF CUTOFF FREQ      sysex[16] = (byte)((bankSysex[19] & 0x80) >> 6 | (bankSysex[20] & 0x80) >> 7);      // CHORUS      sysex[17] = (byte)((bankSysex[4] & 0x80) >> 7);      // DCO LFO MOD DEPTH      sysex[18] = (byte)(bankSysex[3] & 0x7F);      // DCO ENV MOD DEPTH      sysex[19] = (byte)(bankSysex[4] & 0x7F);      // DCO AFTER DEPTH (sysex docs say 0-127 value, but real range is 0-15 and it's stored shifted)      sysex[20] = (byte)((bankSysex[0] & 0xF0) >> 1);      // DCO PW/PWM DEPTH      sysex[21] = (byte)(bankSysex[5] & 0x7F);      // DCO PWM RATE      sysex[22] = (byte)(bankSysex[6] & 0x7F);      // VCF CUTOFF FREQ      sysex[23] = (byte)(bankSysex[7] & 0x7F);      // VCF RESONANCE      sysex[24] = (byte)(bankSysex[8] & 0x7F);      // VCF LFO MOD DEPTH      sysex[25] = (byte)(bankSysex[10] & 0x7F);      // VCF ENV MOD DEPTH      sysex[26] = (byte)(bankSysex[9] & 0x7F);      // VCF KEY FOLLOW (sysex docs say 0-127 value, but real range is 0-15 and it's stored shifted)      sysex[27] = (byte)((bankSysex[0] & 0x0F) << 3);      // VCF AFTER DEPTH (sysex docs say 0-127 value, but real range is 0-15 and it's stored shifted)      sysex[28] = (byte)((bankSysex[1] & 0xF0) >> 1);      // VCA LEVEL      sysex[29] = (byte)(bankSysex[11] & 0x7F);      // VCA AFTER DEPTH (sysex docs say 0-127 value, but real range is 0-15 and it's stored shifted)      sysex[30] = (byte)((bankSysex[1] & 0x0F) << 3);      // LFO RATE      sysex[31] = (byte)(bankSysex[12] & 0x7F);      // LFO DELAY TIME      sysex[32] = (byte)(bankSysex[13] & 0x7F);      // ENV T1      sysex[33] = (byte)(bankSysex[14] & 0x7F);      // ENV L1      sysex[34] = (byte)(bankSysex[15] & 0x7F);      // ENV T2      sysex[35] = (byte)(bankSysex[16] & 0x7F);      // ENV L2      sysex[36] = (byte)(bankSysex[17] & 0x7F);      // ENV T3      sysex[37] = (byte)(bankSysex[18] & 0x7F);      // ENV L3      sysex[38] = (byte)(bankSysex[19] & 0x7F);      // ENV T4      sysex[39] = (byte)(bankSysex[20] & 0x7F);      // ENV KEY FOLLOW (sysex docs say 0-127 value, but real range is 0-15 and it's stored shifted)      sysex[40] = (byte)((bankSysex[2] & 0xF0) >> 1);      // CHORUS RATE      sysex[41] = (byte)((bankSysex[27] & 0xC0) >> 6 | (bankSysex[28] & 0xC0) >> 4                       | (bankSysex[29] & 0xC0) >> 2 | (bankSysex[30] & 0x40));      // BENDER RANGE      sysex[42] = (byte)(bankSysex[2] & 0x0F);      // TONE NAME (10 bytes)      for (int i = 0; i < 10; i++)      {        sysex[43+i] = (byte)(bankSysex[i+21] & 0x3F);      }      IPatch p = new Patch(sysex);      return p;  }