Package org.jjazz.harmony.api
Class ChordTypeDatabase
java.lang.Object
org.jjazz.harmony.api.ChordTypeDatabase
Manage the list of recognized chordtypes and their aliases.
Used to retrieve instances of ChordTypes (which are unmutable). User can alter aliases which are saved as preferences.
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
static class
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an alias for the specified chord type.getAliases
(ChordType ct) Get the aliases of the specified chord type.getChordType
(int i) Get a chord type from the database.Get a chord type from the database from a String description.getChordType
(List<Degree> degrees) Get the ChordType which match the specified degrees.int
The index of the ct in the database.Get all the ChordTypes of the database.static ChordTypeDatabase
int
getSize()
Get the number of chord types in the database.int
guessExtension
(String ctStr) Try to guess where the extension part of a chord type string starts.void
final void
Clear all the user changes.
-
Method Details
-
getInstance
-
guessExtension
Try to guess where the extension part of a chord type string starts.For example for "madd9", return 1 because base=m and extension="add9". Should be used only if a ChordType.getOriginalName() differs from ChordType.getName().
- Parameters:
ctStr
- A chord type string like "", "sus7", "7dim7M", "Maj7aug", "madd9", etc.- Returns:
- The index of the first char of the extension. -1 if no extension found.
-
addAlias
Add an alias for the specified chord type.An alias can be used by only one chord type.
- Parameters:
ct
-alias
- e.g. "-7" for the "m7" chord type- Throws:
IllegalArgumentException
- If ct is not part of this databaseChordTypeDatabase.InvalidAliasException
- If alias is invalid, e.g. it's already used by a different chord type.
-
resetAliases
-
resetAliasesToDefault
public final void resetAliasesToDefault()Clear all the user changes. -
getAliases
Get the aliases of the specified chord type.Use the aliases stored in the preferences if available, otherwise return the default aliases.
- Parameters:
ct
-- Returns:
-
getChordTypes
Get all the ChordTypes of the database.- Returns:
-
getSize
public int getSize()Get the number of chord types in the database.- Returns:
-
getChordType
Get a chord type from the database.- Parameters:
i
- The index of the chord type- Returns:
-
getChordType
Get a chord type from the database from a String description.The String must match the chord type name or one of its aliases.
- Parameters:
s
- The String, e.g. "m7".- Returns:
- A ChordType, null if no ChordType correspond to s.
-
getChordType
Get the ChordType which match the specified degrees.- Parameters:
degrees
-- Returns:
- Can be null
-
getChordTypeIndex
The index of the ct in the database.- Parameters:
ct
-- Returns:
- -1 if ct is not present in the database.
-