Class Chord


  • public class Chord
    extends Object
    A chord rooted in a specific note. Each chord is defined by its Chord.ChordType, such as "seventh" or "minor sixth", and its root note. The class offers methods for accessing the notes in the chord.
    • Constructor Detail

      • Chord

        public Chord()
    • Method Detail

      • lookup

        public static Chord lookup​(String root,
                                   Chord.ChordType type)
        Looks up a chord based on its root note and its chord type.
        Parameters:
        root -
        type -
        Returns:
      • lookup

        public static Chord lookup​(String chordName)
        Looks up a chord based on its name, such as "Cmj7".
        Parameters:
        chordName -
        Returns:
      • getNotes

        public Set<Integer> getNotes()
        Returns the notes of the chord, as relative notes in the sense of Note.
        Returns:
      • isAllowedBassNote

        public boolean isAllowedBassNote​(Note note)
        Checks if the given note is allowed in the bass part of this chord.
        Parameters:
        note -
        Returns:
      • getKey

        public Key getKey()
        Returns the key to which this chord belongs. This is a combination of the chord's root and its mode, as per Chord.ChordType.getMode(). Thus, the Cmaj7 chord is mapped to the key of C major, and the Am6 chord is mapped to the key of A minor. These keys can be used to spell the accidentals in the chord correctly.
        Returns:
      • getRoot

        public int getRoot()
        Returns the root note of the chord, as a relative note in the sense of Note.
        Returns:
      • getType

        public Chord.ChordType getType()
        Returns the type of this chord.
        Returns:
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object