Class ChordSymbol
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
ExtChordSymbol
Examples : "Cm7", "F7b9", "Dbalt", "Amaj7/F#".
This is an immutable class.
-
Constructor Summary
ConstructorsConstructorDescriptionA "C" chord symbol.ChordSymbol(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()voiddump()Print the ChordSymbol, its aliases and degreesbooleanComparison is based on rootNote and bassNote relative pitch, ChordType and originalName.getChord()Get the chord corresponding to this ChordSymbol.Return the most probable accidental to use when representing black key notes based on this chord symbol.getName()The standard ChordSymbol recognized by JJazzLab.Return the name used at creation if the ChordType(String) constructor has been used.static ChordSymbolCreate a random chord symbol: random root note and chord type, sometimes with a different bass note.intgetRelativePitch(int relPitch, ChordSymbol destCs) Get the equivalent of relPitch but for the specified destination chord symbol.intReturn the relative pitch corresponding to the specified degree index for this chord symbol.intReturn the relative pitch corresponding to the specified degree based on this chord symbol root note.getSimplified(int nbMaxDegrees) Get a simplified ChordSymbol by keeping only the first nbMaxDegrees degrees.getTransposedChordSymbol(int t, Note.Accidental alt) Get a transposed ChordSymbol.inthashCode()booleanCompare chord types of 2 chord symbols.booleanCheck if chord sympbol has a bass note different from the root note.toString()
-
Constructor Details
-
ChordSymbol
public ChordSymbol()A "C" chord symbol. -
ChordSymbol
-
ChordSymbol
-
ChordSymbol
Construct a ChordSymbol from a string.All notes are made uppercase. Unusual notes Cb/B#/E#/Fb are renamed to B/C/F/E. Bass note is removed if identical to root note. Root accidental for natural notes is set based on usage (e.g. sharp for a D chord, flat for an F chord).
Note that the special "NC" chord is not supported (see ExtChordSymbol.get()).
- Parameters:
str- A string like "Cm7", "Abmaj7", "Bm7b5", "G#MAJ7", "cm/eb"- Throws:
ParseException
-
-
Method Details
-
clone
-
getRootNote
- Returns:
- Can not be null
-
getBassNote
- Returns:
- Can not be null. Can be the root note if no different bass note was specified at construction.
-
isSlashChord
public boolean isSlashChord()Check if chord sympbol has a bass note different from the root note.- 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 a chord type alias was used. First char is always upper case.
- Returns:
-
getDefaultAccidental
Return the most probable accidental to use when representing black key notes based on this chord symbol.- Returns:
-
toString
-
dump
public void dump()Print the ChordSymbol, its aliases and degrees -
getTransposedChordSymbol
Get a transposed ChordSymbol.The originalName is also updated.
- Parameters:
t- The amount of transposition in semi-tons.alt- If null, accidental of returned root and bass notes is unchanged. If not null use alt as root and bass notes accidental.- 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.First note of the chord is the relative pitch of the root note (bass note is ignored), then next notes are above the root note, with extension notes 9-11-13 at the end.
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.
Note that it may return -1 even for degreeIndex=THIRD_OR_FOURTH when applied to a C2 chord.
- Parameters:
di-- Returns:
- -1 if no such degreeIndex.
-
getRelativePitch
Return the relative pitch corresponding to the specified degree based on this chord symbol root note.Ex: this=E7, degree=THIRT_FLAT, return G
- Parameters:
d-- Returns:
- A relative pitch.
-
equals
-
hashCode
-
getRandom
Create a random chord symbol: random root note and chord type, sometimes with a different bass note.- Returns:
-