This is an implementation of IBankDriver and the base class for bank drivers which use Patch.

Declaration : BankDriver extends Driver, numPatches, numColums
for default canHoldPatch : singleSysexID, singleSize
constructor : Takes (String patchType, String authors, int numPatches, int numColums)
IDriver interface methods : isSingleDriver false, isBankDriver true, isConverter false.
IPatchDriver interface methods : storePatch(patch, bankNum, patchNum), hasEditor(), editPatch(bank),
for IPatch interface methods : getPatchName(bank), setPatchName(bank,name)
for IBankPatch interface methods : getNumPatches, getNumColums, canHoldPatch, putPatch, deletePatch, getPatch, getPatchName, setPatchName.


abstract public class BankDriver extends Driver implements IPatchDriver {

private final int numPatches;
The Number of Patches the Bank holds.
private final int numColumns;
How many columns to use when displaying the patches as a table.

for default canHoldPatch

protected String singleSysexID;
The Sysex header for the patches which go in this bank. This
should be same value as the sysexID field of the
single driver. It can be up to 16 bytes and have wildcards in the form of
an asterix *
or a dot . (Who knows the difference ?)
see Driver#sysexID and #canHoldPatch
protected int singleSize;
The size of the patches which go in this bank.
see #canHoldPatch


public BankDriver(String patchType, String authors,
int numPatches, int numColumns)
super(patchType, authors);
this.numPatches = numPatches;
this.numColumns = numColumns;
Creates a new BankDriver instance.
patchType The patch type. eg. "Bank", "Multi Bank", "Drum Bank", etc.
authors The names of the authors of this driver.
numPatches The Number of Patches the Bank holds.
numColumns How many columns to use when displaying the patches as a table.

IDriver interface methods

public final boolean isSingleDriver()
{return false;}
public final boolean isBankDriver()
{return true;}
public final boolean isConverter()
{return false;}

IPatchDriver interface methods

protected void storePatch(Patch bank, int bankNum, int patchNum) {
Store the bank to a given bank on the synth. Ignores the patchNum parameter. Should probably be overridden in most drivers
see Patch#send(int, int)
public boolean hasEditor() {
return true;}
see Patch#hasEditor()
protected JSLFrame editPatch(Patch bank) {
return new BankEditorFrame(bank);}
Creates a default bank editor window to edit this bank.
see Patch#edit()
or the example: YamahaFS1RBankEditor

for IPatch interface methods

public String getPatchName(Patch bank) {
Most Banks have no name.
return "-";}

Get name of the bank.
see Patch#getName()
public void setPatchName(Patch bank, String name) {
Most Banks have no name.}
Set name of the bank.
see Patch#setName(String)

for IBankPatch interface methods

public final int getNumPatches() {
return numPatches;}
see Patch#getNumPatches()
public final int getNumColumns() {
return numColumns;}
see Patch#getNumColumns()
protected boolean canHoldPatch(Patch p) {
if ((singleSize != p.sysex.length) && (singleSize != 0))
return false;

String patchString = p.getPatchHeader().toString();
StringBuffer driverString = new StringBuffer(singleSysexID);
for (int j = 0; j < driverString.length(); j++)
if (driverString.charAt(j) == '*')
driverString.setCharAt(j, patchString.charAt(j));
return (driverString.toString().equalsIgnoreCase
(patchString.substring(0, driverString.length()))); }
Compares first the size and then the header
of a Single Patch to this driver
to see if this bank can hold the patch.
see Patch#put(IPatch, int) and Driver#supportsPatch
abstract protected void putPatch(Patch bank, Patch single, int patchNum);
Puts a patch into the bank, converting it as needed. single is already checked by
canHoldPatch, although it was not. (I guess "was not" refers to an older version of JSynthLib)
see Patch#put(IPatch, int)
protected void deletePatch(Patch single, int patchNum) {
setPatchName(single, patchNum, " "); }
Delete a patch.
see Patch#delete(int)
abstract protected Patch getPatch(Patch bank, int patchNum);
Gets a patch from the bank, converting it as needed.
see Patch#get(int)
abstract protected String getPatchName(Patch bank, int patchNum);
Get the name of the patch at the given number patchNum.
see Patch#getName(int)
abstract protected void setPatchName(Patch bank, int patchNum, String name);
Set the name of the patch at the given number <code>patchNum</code>.
see Patch#setName(int, String)