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
Modifier and TypeClassDescriptionstatic enum
An ordered list of chord symbol degrees.static enum
All chord symbols must belong to 1 of these 5 groups. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Constant used in the constructor to specify when a degree is Not Present. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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. "7" for C7#11getChord()
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. "#11" for C7#11The ordered list of DegreeIndexes starting from NINTH.The list of "most important Degrees" indexes for this chord type, in the descending order.getName()
E.g. "7#11" for C7#11int
getPitch
(Degree.Natural nd, int rootPitch) Calculate the pitch of degree nd if chord's root=rootPitch and chord's type=this.int
Compute how much "similar" is the specified ChordType with this object.getSimplified
(int nbMaxDegrees) Get a simplified ChordType by keeping only the first nbMaxDegrees degrees.int
hashCode()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isMajor()
boolean
isMinor()
boolean
isNinth()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isSixth()
boolean
isSus()
True if family is Family.SUS (no third degree).boolean
toString()
-
Field Details
-
NOT_PRESENT
public static final int NOT_PRESENTConstant used in the constructor to specify when a degree is Not Present.- See Also:
-
-
Method Details
-
getExtensionDegreeIndexes
The ordered list of DegreeIndexes 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.
-
getFamily
-
getBase
E.g. "7" for C7#11- Returns:
-
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
E.g. "7#11" for C7#11- Returns:
-
getDegrees
The ordered list of each ChordDegree composing this chord.Order is ROOT, THIRD or FOURTH, FIFTH, [SIXTH_OR_THIRTEENTH(if==sixth)], [SEVENTH], [NINTH], [ELEVENTH], [SIXTH_OR_THIRTEENTH(if==extension)].
- Returns:
-
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.
-
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 th 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
-
getSimilarityIndex
Compute how much "similar" is the specified ChordType with this object.Index is calculated by adding the weights below until a mismatch is found. Identical ChordTypes have a similarity index of 63. For example C7 and Cm7 have a similarity index=0 (different families). C7 and C9 have a similarity index=32+16+8=56 (same family, same fifth, same sixth_seventh, but extension1 mismatch).
Same ChordType.FAMILY:32
Same DegreeIndex.FIFTH: 16
Same DegreeIndex.SIXTH_SEVENTH: 8
Same DegreeIndex.EXTENSION1: 4
Same DegreeIndex.EXTENSION2: 2
Same DegreeIndex.EXTENSION3: 1- Parameters:
ct
-- Returns:
-
getPitch
Calculate the pitch of degree nd if chord's root=rootPitch and chord's type=this.- Parameters:
rootPitch
-nd
-- Returns:
- A Midi pitch, or -1 if nd is not present in this chord pitch.
-
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
-
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 (if alteration is needed).
-
equals
-
hashCode
public int hashCode()
-