Package org.jjazz.harmony.api
Class ChordSymbol
java.lang.Object
org.jjazz.harmony.api.ChordSymbol
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ExtChordSymbol
A jazz chord symbol.
Examples : "Cm7", "F7b9", "Dbalt", "Amaj7/F#".
This is an immutable class.
-
Constructor Summary
ConstructorDescriptionChordSymbol
(String str) Construct a ChordSymbol from a string.ChordSymbol
(Note rootDg, ChordType ct) ChordSymbol
(Note rootDg, Note bassDg, ChordType ct) -
Method Summary
Modifier and TypeMethodDescriptionclone()
void
dump()
Print the ChordSymbol, its aliases and degreesboolean
Comparison is based on rootNote and bassNote relative pitch, ChordType and originalName.If no bass note defined return getRootNote().getChord()
Get the chord corresponding to this ChordSymbol.getName()
The standard ChordSymbol recognized by JJazzLab.Return the name used at creation if the ChordType(String) constructor has been used.static ChordSymbol
Create a random chord symbol: random root note and chord type, sometimes with a different bass note.int
getRelativePitch
(int relPitch, ChordSymbol destCs) Get the equivalent of relPitch but for the specified destination chord symbol.int
Return the relative pitch corresponding to the specified degree index for this chord symbol.int
Return the relative pitch corresponding to the specified degree of this chord symbol.getSimplified
(int nbMaxDegrees) Get a simplified ChordSymbol by keeping only the first nbMaxDegrees degrees.getTransposedChordSymbol
(int t, Note.Alteration alt) Get a transposed ChordSymbol.int
hashCode()
boolean
Compare chord types of 2 chord symbols.toString()
-
Constructor Details
-
ChordSymbol
public ChordSymbol() -
ChordSymbol
-
ChordSymbol
- Parameters:
rootDg
-bassDg
- If null reuse rootDgct
-
-
ChordSymbol
Construct a ChordSymbol from a string.- Parameters:
str
- A string like "Cm7", "Abmaj7", "Bm7b5", "G#MAJ7", "C/F"- Throws:
ParseException
-
-
Method Details
-
clone
-
getRootNote
-
getBassNote
If no bass note defined return getRootNote().- Returns:
-
getChordType
-
getName
The standard ChordSymbol recognized by JJazzLab.This may differ from the original name.
- Returns:
- See Also:
-
getOriginalName
Return the name used at creation if the ChordType(String) constructor has been used.It may differ from the getName() if an chord type alias was used. First char is always upper case.
- Returns:
-
toString
-
dump
public void dump()Print the ChordSymbol, its aliases and degrees -
getTransposedChordSymbol
Get a transposed ChordSymbol.If this ChordSymbol uses a specific originalName, it will be reused in the returned value.
- Parameters:
t
- The amount of transposition in semi-tons.alt
- If null, alteration of returned root & bass notes is unchanged. If not null use alt as root & bass notes alteration.- Returns:
- A new transposed ChordSymbol.
-
getSimplified
Get a simplified ChordSymbol by keeping only the first nbMaxDegrees degrees.- Parameters:
nbMaxDegrees
- Must be > 2- Returns:
- Can't be null
-
getChord
Get the chord corresponding to this ChordSymbol.The method chooses to use flat or sharp notes depending on the ChordSymbol, using the most "common" tonality associated to the ChordSymbol.
- Returns:
-
toNoteString
- Returns:
- E.g. for D7 return "[D, F#, A, C]"
-
isSameChordType
Compare chord types of 2 chord symbols.- Parameters:
cs
- A chord symbol- Returns:
- True if chords types are equivalent, e.g. for "Am7" and "Ebm-7"
-
getRelativePitch
Get the equivalent of relPitch but for the specified destination chord symbol.Ex: this=Dbm7, destCs=F, relPitch=4=E => return 8=Ab
- Parameters:
relPitch
- A relative pitchdestCs
-- Returns:
- A relative pitch.
-
getRelativePitch
Return the relative pitch corresponding to the specified degree index for this chord symbol.Ex: this=E7, degreeIndex=THIRD_OR_FOURTH, return G#=8.
- Parameters:
di
-- Returns:
- -1 if no such degreeIndex.
-
getRelativePitch
Return the relative pitch corresponding to the specified degree of this chord symbol.Ex: this=E7, degree=THIRT_FLAT, return G
- Parameters:
d
-- Returns:
- A relative pitch.
-
equals
Comparison is based on rootNote and bassNote relative pitch, ChordType and originalName. -
hashCode
public int hashCode() -
getRandom
Create a random chord symbol: random root note and chord type, sometimes with a different bass note.- Returns:
-