Class ChordType
A chordtype is split into a base and an extension, for example with "m7b5" base="m7" extension="b5".
The family tag groups chords that may be similar from an harmonic point of view.
This is an unmutable class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAn ordered list of chord symbol degrees.static enumAll chord symbols must belong to 1 of these 5 groups. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant used in the constructor to specify when a degree is Not Present. -
Constructor Summary
ConstructorsConstructorDescriptionChordType(String b, String e, ChordType.Family f, int i9, int i3, int i11, int i5, int i13, int i7) Build a ChordType. -
Method Summary
Modifier and TypeMethodDescriptionbooleanSame than equals() except that we consider 6th and 7M identical degrees.Try to fit harmonically degree d to this chord type.fitDegreeAdvanced(ChordType.DegreeIndex di, StandardScaleInstance optScale) Rely on fitDegreeAdvanced(Degree d, optScales).fitDegreeAdvanced(Degree d, StandardScaleInstance optScale) Fit harmonically degree d to this chord type.getBase()E.g.getChord()getDegree(int relPitch) Find the chord type's degree who matches the relative pitch.The degree corresponding to the specified DegreeIndex.Find the chord type's degree who matches natural degree nd.The degreeIndex of specified degree.getDegreeMostProbable(int relPitch) Find the most probable degree corresponding to relative pitch for this chordtype.The ordered list of each ChordDegree composing this chord.E.g.The ordered list of DegreeIndexes used by this chord type starting from NINTH.The list of "most important Degrees" indexes for this chord type, in the descending order.getName()E.g.intgetNbCommonDegrees(ChordType ct, boolean sixthMajorSeventhEqual) Count how many initial degrees are identical between 2 chord types.intThe number of degrees used by this ChordType.intgetPitch(Degree.Natural nd, int rootPitch) Calculate the pitch of degree nd if chord's root=rootPitch and chord's type=this.getSimplified(int nbMaxDegrees) Get a simplified ChordType by keeping only the first nbMaxDegrees degrees.booleanbooleanbooleanbooleanbooleanbooleanbooleanisMajor()booleanisMinor()booleanisNinth()booleanbooleanbooleanbooleanbooleanbooleanbooleanisSixth()booleanThe special C2 chord which has no third no fourth no 6/7, but has a ninth.booleanisSus()True if family is Family.SUS (no third degree).booleantoString()
-
Field Details
-
NOT_PRESENT
public static final int NOT_PRESENTConstant used in the constructor to specify when a degree is Not Present.- See Also:
-
-
Constructor Details
-
ChordType
public ChordType(String b, String e, ChordType.Family f, int i9, int i3, int i11, int i5, int i13, int i7) Build a ChordType.Use NOT_PRESENT constant if a degree is not present.
- Parameters:
b- Base of the chord type, e.g. "m7" for "m79"e- Extension of the chord type, e.g. "9" for "m79"f- The family to which this chordtype belongs to.i9- An integer -1, 0 or 1 that represents the status (flat,natural or sharp) of degree 9.i3- An integer -1, 0 that represents the status (flat,natural) of degree 3.i11- An integer 0 or 1 that represents the status (natural or sharp) of degree 11.i5- An integer -1, 0 or 1 that represents the status (flat,natural or sharp) of degree 5.i13- An integer -1, 0 that represents the status (flat,natural) of degree 13.i7- An integer -1, 0 that represents the status (flat,natural) of degree 7.
-
-
Method Details
-
getExtensionDegreeIndexes
The ordered list of DegreeIndexes used by this chord type starting from NINTH.- Returns:
-
getDegreeIndex
The degreeIndex of specified degree.- Parameters:
d-- Returns:
- Can be null if d is not a chord type degree.
-
getDegree
The degree corresponding to the specified DegreeIndex.Ex: Cm9 EXTENSION1=NINTH, THIRD_OR_FOURTH=THIRD_FLAT
Ex: F7 EXTENSION1=null
Ex: F13 EXTENSION1=SIXTH_OR_SIXTEENTH
Ex: C6 EXTENSION1=null- Parameters:
di-- Returns:
- The degree corresponding to specified index. Can be null (even if di==THIRD_OR_FOURTH, see the C2 chord type)
-
getFamily
-
getBase
-
getExtension
E.g. "#11" for C7#11This can be used by a chord symbol renderer to render the extension with an "exponent" format.
- Returns:
-
getName
-
getDegrees
-
getNbDegrees
public int getNbDegrees()The number of degrees used by this ChordType.- Returns:
- A value >= 3
-
getDegree
Find the chord type's degree who matches the relative pitch.Ex. this=7#9, relPitch=3 return NINTH_SHARP
Ex. this=b3, relPitch=3 return THIRD_FLAT
Ex. this=b3, relPitch=4 return NULL- Parameters:
relPitch-- Returns:
- The corresponding degree if it exists, null otherwise.
-
getDegree
Find the chord type's degree who matches natural degree nd.- Parameters:
nd-- Returns:
- The corresponding degree if it exists, e.g. if C7#9, nd=NINTH return NINTH_SHARP, or null if no NINTH.
-
getNbCommonDegrees
Count how many initial degrees are identical between 2 chord types.Examples:
C and Cm: 1, Cm and Cm7: 3, Cm7#9 and Cm9: 4- Parameters:
ct-sixthMajorSeventhEqual- if true we consider 6 and 7M degrees identical.- Returns:
- Minimum value is 1 (root always matches).
-
getDegreeMostProbable
Find the most probable degree corresponding to relative pitch for this chordtype.First try to use getDegree(relPitch). If it returns null, make some assumptions based on the chord type to find the most probable degree.
Ex: Cm7, relPitch=Eb=3, then returns THIRD_FLAT.
Ex: C7, relPitch=Eb=3, then returns NINTH_SHARP.
Ex: C7, relPitch=F=5, then returns FOURTH.
Ex: Cm7, relPitch=F=5, then returns ELEVENTH.- Parameters:
relPitch- relative pitch.- Returns:
- The most probable corresponding degree. Can't be null.
-
getMostImportantDegreeIndexes
The list of "most important Degrees" indexes for this chord type, in the descending order.If some notes need to be omitted, it's better to remove the less important ones first.
Ex: C7=> [THIRD_OR_FOURTH, SIXTH_OR_SEVENTH, FIFTH, ROOT] (ROOT is the less important).
Ex: C6=> [THIRD_OR_FOURTH, SIXTH_OR_SEVENTH, ROOT, FIFTH] (ROOT-SIXTH interval is important).
Ex: C7b5=> [THIRD_OR_FOURTH, FIFTH, SIXTH_OR_SEVENTH, ROOT]
Ex: C9M=> [THIRD_OR_FOURTH, SIXTH_OR_SEVENTH, EXTENSION1, FIFTH, ROOT]
Ex: C9M#11=> [THIRD_OR_FOURTH, SIXTH_OR_SEVENTH, EXTENSION1, FIFTH, ROOT, EXTENSION2]
Ex: C13#11(9)=> [THIRD_OR_FOURTH, SIXTH_OR_SEVENTH, EXTENSION1, FIFTH, ROOT, EXTENSION2, EXTENSION3]- Returns:
- An unmodifiable list
-
fitDegree
Try to fit harmonically degree d to this chord type.ex: d=THIRD, this=m7 => return THIRD_FLAT
ex: d=ELEVENTH_SHARP, this=m7b5 => return FIFTH_FLAT
ex: d=ELEVENTH_SHARP, this=7M => return null
ex: d=SEVENTH, this 6 => return SIXTH_OR_THIRTEENTH- Parameters:
d-- Returns:
- A Degree representing the harmonic conversion of d for this chord type. Can be null if no match.
-
fitDegreeAdvanced
Fit harmonically degree d to this chord type.1/ Try natural degree match using fitDegree() .
2/ If no natural match is possible, fitDegree() on provided optScale (if non null).
ex: d=NINTH_SHARP, scale=DORIAN => return NINTH
ex: d=NINTH, scale=LOCRIAN => return NINTH_FLAT3/ If scale did not help :
Make some assumptions: use the "most common" scale usually associated to a chord type, or just try "best guess"
ex: d=NINTH_FLAT, this=m7, assume scale=DORIAN => return NINTH
ex: d=THIRTEENTH_FLAT, this=m7, assume scale=DORIAN => return SIXTH_OR_THIRTEENTH- Parameters:
d-optScale- Optional scale instance. Can be null.- Returns:
- A Degree representing the harmonic conversion of d for this chord type. Can't be null.
-
fitDegreeAdvanced
Rely on fitDegreeAdvanced(Degree d, optScales).If di does not directly correspond to one of these ChordType degrees, make some assumptions, e.g. if di==DegreeIndex.SIXTH_OR_SEVENTH then try to fit to the seventh degree of this ChordType.
- Parameters:
di-optScale- Optional, can be null.- Returns:
-
getSimplified
Get a simplified ChordType by keeping only the first nbMaxDegrees degrees.- Parameters:
nbMaxDegrees- Must be > 2- Returns:
- Can't be null
-
getPitch
Calculate the pitch of degree nd if chord's root=rootPitch and chord's type=this.- Parameters:
nd-rootPitch-- Returns:
- A Midi pitch, or -1 if nd is not present in this chord pitch.
-
isSpecial2Chord
public boolean isSpecial2Chord()The special C2 chord which has no third no fourth no 6/7, but has a ninth.E.g. true for a "C2" chord.
- Returns:
-
isMinor
public boolean isMinor()- Returns:
- True for Cm7, C°, etc.
-
isMajor
public boolean isMajor()- Returns:
- True if e.g. C7, C, C6, etc. False if e.g. Cm, C7sus etc.
-
isSeventhMinor
public boolean isSeventhMinor()- Returns:
- True for e.g. C7, C7alt, etc.
-
isSeventhMajor
public boolean isSeventhMajor()- Returns:
- True for e.g. C7M, C9M#11, etc.
-
isSeventh
public boolean isSeventh()- Returns:
- True if a seventh (minor or major) is present.
-
isFifthNatural
public boolean isFifthNatural()- Returns:
- True for e.g. C, C7, Cm6
-
isFifthSharp
public boolean isFifthSharp()- Returns:
- True for e.g. C+, C7#5, etc.
-
isFifthFlat
public boolean isFifthFlat()- Returns:
- True for e.g. Cdim, C7b5, etc.
-
isEleventh
public boolean isEleventh()- Returns:
- True if a eleventh (natural or altered) is present.
-
isEleventhNatural
public boolean isEleventhNatural()- Returns:
- True for e.g. Cm11. Note that C7sus will return false, see isSus().
- See Also:
-
isEleventhSharp
public boolean isEleventhSharp()- Returns:
- True for e.g. C7M#11, C7#11.
-
isSus
public boolean isSus()True if family is Family.SUS (no third degree).- Returns:
- True for e.g. Csus, C7sus, C2, ...
-
isSixth
public boolean isSixth()- Returns:
- True if chord does not have a seventh degree (minor or major) but has the SIXTH_OR_THIRTEENTH degree.
-
isThirteenth
public boolean isThirteenth()- Returns:
- True if chord has a seventh degree (minor or major) and the SIXTH_OR_THIRTEENTH degree.
-
isNinth
public boolean isNinth()- Returns:
- True if a ninth (natural or altered) is present.
-
isNinthNatural
public boolean isNinthNatural()- Returns:
- True for e.g. C9, Dbm9
-
isNinthSharp
public boolean isNinthSharp()- Returns:
- True for e.g. C7#9
-
isNinthFlat
public boolean isNinthFlat()- Returns:
- True for e.g. C7b9, etc.
-
toString
-
toDegreeString
- Returns:
- A string like "[1 3b 5 7b 9]" for ChordType "m79"
-
getChord
- Returns:
- A copy of the corresponding Chord with a default C root and flat accidental (if accidental is needed).
-
equalsSixthMajorSeventh
Same than equals() except that we consider 6th and 7M identical degrees.- Parameters:
o-- Returns:
-