Class ChordSymbol

java.lang.Object
org.jjazz.harmony.api.ChordSymbol
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
ExtChordSymbol

public class ChordSymbol extends Object implements Cloneable
A jazz chord symbol.

Examples : "Cm7", "F7b9", "Dbalt", "Amaj7/F#".

This is an immutable class.

  • Constructor Details

    • ChordSymbol

      public ChordSymbol()
    • ChordSymbol

      public ChordSymbol(Note rootDg, ChordType ct)
    • ChordSymbol

      public ChordSymbol(Note rootDg, Note bassDg, ChordType ct)
      Parameters:
      rootDg -
      bassDg - If null reuse rootDg
      ct -
    • ChordSymbol

      public ChordSymbol(String str) throws ParseException
      Construct a ChordSymbol from a string.
      Parameters:
      str - A string like "Cm7", "Abmaj7", "Bm7b5", "G#MAJ7", "C/F"
      Throws:
      ParseException
  • Method Details

    • clone

      public ChordSymbol clone()
    • getRootNote

      public Note getRootNote()
    • getBassNote

      public Note getBassNote()
      If no bass note defined return getRootNote().
      Returns:
    • getChordType

      public ChordType getChordType()
    • getName

      public String getName()
      The standard ChordSymbol recognized by JJazzLab.

      This may differ from the original name.

      Returns:
      See Also:
    • getOriginalName

      public String 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

      public String toString()
      Overrides:
      toString in class Object
    • dump

      public void dump()
      Print the ChordSymbol, its aliases and degrees
    • getTransposedChordSymbol

      public ChordSymbol getTransposedChordSymbol(int t, Note.Alteration alt)
      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

      public ChordSymbol getSimplified(int nbMaxDegrees)
      Get a simplified ChordSymbol by keeping only the first nbMaxDegrees degrees.
      Parameters:
      nbMaxDegrees - Must be > 2
      Returns:
      Can't be null
    • getChord

      public Chord 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

      public String toNoteString()
      Returns:
      E.g. for D7 return "[D, F#, A, C]"
    • isSameChordType

      public boolean isSameChordType(ChordSymbol cs)
      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

      public int getRelativePitch(int relPitch, ChordSymbol destCs)
      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 pitch
      destCs -
      Returns:
      A relative pitch.
    • getRelativePitch

      public int getRelativePitch(ChordType.DegreeIndex di)
      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

      public int getRelativePitch(Degree d)
      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

      public boolean equals(Object obj)
      Comparison is based on rootNote and bassNote relative pitch, ChordType and originalName.

      Overrides:
      equals in class Object
      Parameters:
      obj -
      Returns:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getRandom

      public static ChordSymbol getRandom()
      Create a random chord symbol: random root note and chord type, sometimes with a different bass note.
      Returns: