Class InstrumentBank<T extends Instrument>
- Type Parameters:
T
-
- Direct Known Subclasses:
GM1Bank
,GM2Bank
,GSBank
,GSBank_SC88Pro
,NotSetBank
,XGBank
It must be guaranteed that Instruments have a unique patch name in the bank.
-
Constructor Summary
ConstructorDescriptionInstrumentBank
(String name, int msb, int lsb) Create an empty bank with BankSelectMethod.MSB_LSB.InstrumentBank
(String name, int msb, int lsb, MidiAddress.BankSelectMethod m) Create an InstrumentBank. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInstrument
(T instrument) Add the instrument to the bank.void
clear()
Empty the bank.findInstruments
(String text) Find the instruments whose patchName contains specified text (ignoring case).int
The default BankSelect LSB (Midi control #32).The default BankSelect method.int
The default BankSelect MSB (Midi control #0).Get all the Drums/Percussion instruments.getDrumsInstruments
(DrumKit kit, boolean tryHarder) Get all the drums/percussion instruments which match the specified DrumKit.int
getIndex
(Instrument ins) The index of the specified instrument.getInstrument
(int index) Get the instrument which is specified index in the bank.getInstrument
(String patchName) Get the instrument whose patchName matches (ignoring case) the specified name.getInstrument
(MidiAddress address) Get the instrument at the specified MidiAddress.Get all the instruments of the bank.getInstruments
(Predicate<Instrument> tester) Get all the instruments which match the specified predicate.Get the instruments whose substitute's family is f.Get the instruments whose substitute is sub.Get all the DrumKit.KeyMaps used by this bank.The MidiSynth this bank belongs to.getName()
The name of the bank.The next instrument in the database after the specified instrument.Get the non Drums/Percussion instruments.The previous instrument in the database after the specified instrument.int
getSize()
The number of instruments in the bank.getTypes()
Get all the DrumKit.Types used by this bank.void
removeInstrument
(T instrument) Remove an Instrument from this bank.void
setMidiSynth
(MidiSynth synth) Associate a MidiSynth to this bank.toString()
-
Constructor Details
-
InstrumentBank
Create an empty bank with BankSelectMethod.MSB_LSB.- Parameters:
name
-msb
-lsb
-
-
InstrumentBank
Create an InstrumentBank.- Parameters:
name
-msb
- The default Most Significant Byte or "Control 0".lsb
- The default Least Significant Byte or "Control 32"m
- The default bank select method. Can't be null.
-
-
Method Details
-
setMidiSynth
Associate a MidiSynth to this bank.IMPORTANT: this method can be called only once (because a bank can't be assigned to 2 different MidiSynths).
It is the responsibility of the specified MidiSynth to add the bank.
- Parameters:
synth
- A non null value, the MidiSynth this InstrumentBank belongs to
-
getMidiSynth
The MidiSynth this bank belongs to.- Returns:
- Can be null
-
getDefaultBankSelectMethod
The default BankSelect method.Note that individual instruments belonging to this bank can have a different BankSelect method.
- Returns:
- Can't be null.
-
getDefaultBankSelectMSB
public int getDefaultBankSelectMSB()The default BankSelect MSB (Midi control #0).Note that individual instruments belonging to this bank can have a different BankSelect MSB.
- Returns:
- [0;127] Bank Select Most Significant Byte (MIdi control #0).
-
getDefaultBankSelectLSB
public int getDefaultBankSelectLSB()The default BankSelect LSB (Midi control #32).Note that individual instruments belonging to this bank can have a different BankSelect LSB.
- Returns:
- [0;127] Bank Select Most Significant Byte (Midi control #32)
-
addInstrument
Add the instrument to the bank.The method sets the instrument's bank to this bank. It is the responsibility of the caller to check that instrument's patchName is not used twice in the bank.
- Parameters:
instrument
-
-
removeInstrument
Remove an Instrument from this bank.- Parameters:
instrument
-
-
getKeyMaps
Get all the DrumKit.KeyMaps used by this bank.- Returns:
-
getTypes
Get all the DrumKit.Types used by this bank.- Returns:
-
clear
public void clear()Empty the bank. -
getSize
public int getSize()The number of instruments in the bank.- Returns:
-
getName
The name of the bank.- Returns:
-
getIndex
The index of the specified instrument.- Parameters:
ins
-- Returns:
- -1 if not found
-
getInstruments
Get all the instruments of the bank.- Returns:
-
getNextInstrument
The next instrument in the database after the specified instrument.Return the 1st element of the database if ins is the last element.
- Parameters:
ins
-- Returns:
-
getPreviousInstrument
The previous instrument in the database after the specified instrument.Return the 1st element of the database if ins is the last element.
- Parameters:
ins
-- Returns:
-
getInstrument
Get the instrument whose patchName matches (ignoring case) the specified name.- Parameters:
patchName
-- Returns:
- null if not found
-
getInstrument
Get the instrument at the specified MidiAddress.- Parameters:
address
-- Returns:
- null if not found
-
getInstrument
Get the instrument which is specified index in the bank.- Parameters:
index
-- Returns:
-
getNonDrumsInstruments
Get the non Drums/Percussion instruments.- Returns:
- Returned instruments have isDrumKit() set to false.
-
getDrumsInstruments
Get all the Drums/Percussion instruments.- Returns:
- Returned instruments have isDrumKit() set to true.
-
getDrumsInstruments
Get all the drums/percussion instruments which match the specified DrumKit.- Parameters:
kit
-tryHarder
- If true and no instrument matched the specified kit, then try again but with a more flexible matching algorithm. Default implementation starts a second search using kit.Type.STANDARD.- Returns:
- Can be empty.
-
getInstrumentsFromSubstitute
Get the instruments whose substitute is sub.- Parameters:
sub
- Can be null- Returns:
-
getInstruments
Get all the instruments which match the specified predicate.- Parameters:
tester
-- Returns:
-
getInstrumentsFromFamily
Get the instruments whose substitute's family is f.- Parameters:
f
- Can't be null- Returns:
-
findInstruments
Find the instruments whose patchName contains specified text (ignoring case).- Parameters:
text
-- Returns:
-
toString
-