public abstract class AbstractDriver extends Object implements IDriver
Modifier and Type | Field and Description |
---|---|
protected String[] |
bankNumbers
Array holding names or numbers for all banks.
|
protected int |
checksumEnd
End of range that Checksum covers.
|
protected int |
checksumOffset
Offset of checksum byte.
|
protected int |
checksumStart
Start of range that Checksum covers.
|
protected int |
deviceIDoffset
Offset of deviceID in sysex.
|
protected org.apache.log4j.Logger |
log |
protected int |
numSysexMsgs
Number of sysex messages in patch dump.
|
protected int |
patchNameSize
Number of characters in the patch name.
|
protected int |
patchNameStart
The offset in the patch where the patchname starts.
|
protected String[] |
patchNumbers
Array holding names/numbers for all patches.
|
protected int |
patchSize
The size of the patch this Driver supports (or 0 for variable).
|
protected String |
sysexID
The hex header that sysex files of the format this driver supports will
have.
|
protected SysexHandler |
sysexRequestDump
SysexHandler object to request dump.
|
protected int |
trimSize
The size of the patch for trimming purposes.
|
Constructor and Description |
---|
AbstractDriver(String patchType,
String authors)
Creates a new
Driver instance. |
Modifier and Type | Method and Description |
---|---|
void |
calculateChecksum(byte[] sysex,
int start,
int end,
int ofs)
Caluculate check sum of a byte array
sysex . |
void |
calculateChecksum(Patch p)
Calculate check sum of a
Patch . |
protected void |
calculateChecksum(Patch patch,
int start,
int end,
int offset)
Calculate check sum of a
Patch . |
boolean |
canCreatePatch()
Check if this driver supports creating a new patch.
|
protected Patch |
createNewPatch()
Create a new Patch.
|
Patch |
createPatch()
Create a new Patch for this driver.
|
Patch |
createPatch(byte[] sysex)
Create a patch from a byte array for the driver.
|
Patch[] |
createPatches(SysexMessage[] msgs)
Create an array of patches from an array of SysexMessage for the driver.
|
protected String[] |
generateNumbers(int min,
int max,
String format)
A utility method to generates an array of formatted numbers.
|
String |
getAuthors()
return the names of the authors of this driver.
|
String[] |
getBankNumbers()
Returns String[] returns full list of bankNumbers.
|
int |
getChannel()
Return MIDI channel number.
|
int |
getChecksumEnd() |
int |
getChecksumOffset() |
int |
getChecksumStart() |
Device |
getDevice()
Return
Device with which this driver go.. |
int |
getDeviceID()
Return MIDI devide ID.
|
int |
getDeviceIDoffset() |
protected String |
getManufacturerName()
Return the name of manufacturer of synth.
|
protected String |
getModelName()
Return the name of model of synth.
|
protected PatchFactory |
getPatchFactory() |
int |
getPatchNameSize()
Getter of patchNameSize.
|
int |
getPatchNameStart() |
String[] |
getPatchNumbers()
Returns String[] returns full list of patchNumbers.
|
int |
getPatchSize()
Return the size of the patch which the driver handles.
|
String |
getPatchType()
return type of patch which the driver handles.
|
protected String |
getSynthName()
Return the personal name of the synth.
|
String |
getSysexID() |
SysexHandler |
getSysexRequestDump() |
int |
getTrimSize() |
void |
playPatch(Patch p)
Play note.
|
void |
requestPatchDump(int bankNum,
int patchNum)
Request the synth to send a patch dump.
|
void |
send(byte[] sysex)
Send Sysex byte array data to MIDI outport.
|
void |
send(int status,
int d1)
Send ShortMessage to MIDI outport.
|
void |
send(int status,
int d1,
int d2)
Send ShortMessage to MIDI outport.
|
void |
send(MidiMessage msg)
Send a MidiMessage to the MIDI outport for this driver.
|
void |
sendPatch(Patch p)
Sends a patch to the synth's edit buffer.
|
protected void |
sendPatchWorker(Patch p)
Set Device ID and send the sysex data to MIDI output.
|
protected void |
setBankNum(int bankNum)
Send Control Change (Bank Select) MIDI message.
|
void |
setBankNumbers(String[] bankNumbers) |
void |
setChecksumEnd(int checksumEnd) |
void |
setChecksumOffset(int checksumOffset) |
void |
setChecksumStart(int checksumStart) |
void |
setDevice(Device d)
Set
Device with which this driver go. |
void |
setDeviceIDoffset(int deviceIDoffset) |
void |
setPatchNameSize(int patchNameSize) |
void |
setPatchNameStart(int patchNameStart) |
protected void |
setPatchNum(int patchNum)
Send Program Change MIDI message.
|
void |
setPatchNumbers(String[] patchNumbers) |
void |
setPatchSize(int patchSize) |
void |
setSysexID(String sysexID) |
void |
setSysexRequestDump(SysexHandler sysexRequestDump) |
void |
setTrimSize(int trimSize) |
boolean |
supportsPatch(String patchString,
byte[] sysex)
Compares the header & size of a Patch to this driver to see if this
driver is the correct one to support the patch.
|
String |
toString()
Returns full name for referring to this Driver.
|
int |
trimSysex(Patch patch)
This method trims a patch, containing more than one real patch to a
correct size.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
editPatch, getPatchName, hasEditor, isBankDriver, isConverter, isSingleDriver, setPatchName, storePatch
protected final transient org.apache.log4j.Logger log
protected int patchSize
supportsPatch(java.lang.String, byte[])
protected String sysexID
*
). (ex. "F041**003F12"
)supportsPatch(java.lang.String, byte[])
protected String[] patchNumbers
getPatchNumbers()
,
#getPatchNumbersForStore
,
DriverUtil#generateNumbers
protected String[] bankNumbers
getBankNumbers()
,
DriverUtil#generateNumbers
protected int deviceIDoffset
sendPatchWorker
method.protected SysexHandler sysexRequestDump
requestPatchDump
method.requestPatchDump(int, int)
,
SysexHandler
protected int checksumOffset
Need to be set if default calculateChecksum(Patch)
method is
used.
calculateChecksum(Patch)
protected int checksumStart
Need to be set if default calculateChecksum(Patch)
method is
used.
calculateChecksum(Patch)
protected int checksumEnd
Need to be set if default calculateChecksum(Patch)
method is
used.
calculateChecksum(Patch)
protected int patchNameStart
protected int patchNameSize
protected int trimSize
protected int numSysexMsgs
public final String getPatchType()
IDriver
getPatchType
in interface IDriver
public final String getAuthors()
IDriver
getAuthors
in interface IDriver
public void setDevice(Device d)
IDriver
Device
with which this driver go.public final Device getDevice()
IDriver
Device
with which this driver go..public boolean supportsPatch(String patchString, byte[] sysex)
supportsPatch
in interface IDriver
patchString
- the result of p.getPatchHeader()
.sysex
- a byte array of sysex messagetrue
if this driver supports the Patch.patchSize
,
sysexID
public int getPatchSize()
IDriver
SysexGetDialog
uses this to estimate timeout value.getPatchSize
in interface IDriver
SysexGetDialog
public String[] getPatchNumbers()
IDriver
getPatchNumbers
in interface IDriver
DriverUtil#generateNumbers
public String[] getBankNumbers()
IDriver
getBankNumbers
in interface IDriver
DriverUtil#generateNumbers
public void sendPatch(Patch p)
Override this in the subclass if parameters or warnings need to be sent to the user (aka if the particular synth does not have a edit buffer or it is not MIDI accessable).
sendPatch
in interface IDriver
Patch.send()
,
ISinglePatch#send()
protected final void sendPatchWorker(Patch p)
sendPatch(Patch)
public final void send(byte[] sysex)
sysex
- a byte array of Sysex data. If it has checksum, the checksum
must be calculated before calling this method.public void playPatch(Patch p)
playPatch
in interface IDriver
Patch.play()
,
ISinglePatch#play()
public final void send(MidiMessage msg)
IDriver
public Patch[] createPatches(SysexMessage[] msgs)
IDriver
requestPatchDump(int, int)
.createPatches
in interface IDriver
msgs
- an array of SysexMessage.IPatch
value.IDriver.requestPatchDump(int, int)
,
SysexGetDialog
public Patch createPatch(byte[] sysex)
IDriver
IDriver.supportsPatch()
returns true
.createPatch
in interface IDriver
sysex
- a byte array of sysex data.IPatch
object.IDriver.supportsPatch(String, byte[])
,
DriverUtil#createPatch(byte[])
protected final String getManufacturerName()
protected final String getModelName()
protected final String getSynthName()
public final int getDeviceID()
IDriver
getDeviceID
in interface IDriver
public final int getChannel()
getChannel
in interface IDriver
public int getPatchNameSize()
IDriver
getPatchNameSize
in interface IDriver
public void calculateChecksum(Patch p)
Patch
.
Need to be overridden if a patch is consist from multiple SysEX messages.
calculateChecksum
in interface IDriver
p
- a Patch
valueprotected final void calculateChecksum(Patch patch, int start, int end, int offset)
Patch
.
This method is called by calculateChecksum(Patch). The checksum calculation method of this method is used by Roland, YAMAHA, etc. Override this for different checksum calculation method.
Compatibility Note: This method became 'static' method.
patch
- a Patch
valuestart
- start offsetend
- end offsetoffset
- offset of the checksum datacalculateChecksum(Patch)
public int trimSysex(Patch patch)
trimSysex
in interface IDriver
patch
- the patch, which should be trimmed to the right sizefixPatch(Patch, String)
,
IDriver.createPatches(SysexMessage[])
protected void setBankNum(int bankNum)
IDriver.storePatch(Patch, int, int)
public void requestPatchDump(int bankNum, int patchNum)
sysexRequestDump
is not null
, a request dump message is sent. Otherwise a
dialog window will prompt users.requestPatchDump
in interface IDriver
IDriver.requestPatchDump(int, int)
,
SysexHandler
protected void setPatchNum(int patchNum)
IDriver.storePatch(Patch, int, int)
public final void send(int status, int d1, int d2)
public final void send(int status, int d1)
public boolean canCreatePatch()
canCreatePatch
in interface IDriver
IDriver.createPatch()
public String toString()
IDriver
public final Patch createPatch()
IDriver
createPatch
in interface IDriver
protected Patch createNewPatch()
IDriver.createPatch()
,
createPatch()
protected PatchFactory getPatchFactory()
protected String[] generateNumbers(int min, int max, String format)
patchNumbers = generateNumbers(1, 10, "Patch 00");setups the following array,
{ "Patch 01", "Patch 02", "Patch 03", "Patch 04", "Patch 05" "Patch 06", "Patch 07", "Patch 08", "Patch 09", "Patch 10" }
min
- minumux valuemax
- maximum valueformat
- pattern String for java.text.DecimalFormatDecimalFormat
,
IDriver.getPatchNumbers()
,
IPatchDriver.getPatchNumbersForStore()
,
IDriver.getBankNumbers()
public void calculateChecksum(byte[] sysex, int start, int end, int ofs)
IDriver
sysex
.
The checksum calculation method of this method is used by Roland, YAMAHA, etc.
Compatibility Note: This method became 'static' method.
calculateChecksum
in interface IDriver
sysex
- a byte arraystart
- start offsetend
- end offsetofs
- offset of the checksum datacalculateChecksum(Patch)
public String getSysexID()
getSysexID
in interface IDriver
public void setSysexID(String sysexID)
setSysexID
in interface IDriver
public int getDeviceIDoffset()
getDeviceIDoffset
in interface IDriver
public void setDeviceIDoffset(int deviceIDoffset)
setDeviceIDoffset
in interface IDriver
public SysexHandler getSysexRequestDump()
getSysexRequestDump
in interface IDriver
public void setSysexRequestDump(SysexHandler sysexRequestDump)
setSysexRequestDump
in interface IDriver
public int getChecksumOffset()
getChecksumOffset
in interface IDriver
public void setChecksumOffset(int checksumOffset)
setChecksumOffset
in interface IDriver
public int getChecksumStart()
getChecksumStart
in interface IDriver
public void setChecksumStart(int checksumStart)
setChecksumStart
in interface IDriver
public int getChecksumEnd()
getChecksumEnd
in interface IDriver
public void setChecksumEnd(int checksumEnd)
setChecksumEnd
in interface IDriver
public int getPatchNameStart()
getPatchNameStart
in interface IDriver
public void setPatchNameStart(int patchNameStart)
setPatchNameStart
in interface IDriver
public int getTrimSize()
getTrimSize
in interface IDriver
public void setTrimSize(int trimSize)
setTrimSize
in interface IDriver
public void setPatchSize(int patchSize)
setPatchSize
in interface IDriver
public void setPatchNumbers(String[] patchNumbers)
setPatchNumbers
in interface IDriver
public void setBankNumbers(String[] bankNumbers)
setBankNumbers
in interface IDriver
public void setPatchNameSize(int patchNameSize)
setPatchNameSize
in interface IDriver
Copyright © 2014. All Rights Reserved.