Package org.jfugue.theory
Class Chord
- java.lang.Object
-
- org.jfugue.theory.Chord
-
- All Implemented Interfaces:
PatternProducer
public class Chord extends java.lang.Object implements PatternProducer
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Map<java.lang.String,Intervals>
chordMap
static Intervals
DIMINISHED_INTERVALS
static Intervals
DIMINISHED_SEVENTH_INTERVALS
static java.util.Map<java.lang.String,java.lang.String>
humanReadableMap
static Intervals
MAJOR_INTERVALS
static Intervals
MAJOR_SEVENTH_INTERVALS
static Intervals
MAJOR_SEVENTH_SIXTH_INTERVALS
static Intervals
MINOR_INTERVALS
static Intervals
MINOR_SEVENTH_INTERVALS
static Intervals
MINOR_SEVENTH_SIXTH_INTERVALS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addChord(java.lang.String name, java.lang.String intervalPattern)
static void
addChord(java.lang.String name, Intervals intervalPattern)
boolean
equals(java.lang.Object o)
static Chord
fromNotes(java.lang.String noteString)
static Chord
fromNotes(java.lang.String[] noteStrings)
static Chord
fromNotes(Note[] notes)
Note
getBassNote()
static java.lang.String[]
getChordNames()
java.lang.String
getChordType()
static java.lang.String
getChordType(Intervals intervals)
static java.lang.String
getHumanReadableName(java.lang.String chordName)
Returns a human readable chord name if one exists, otherwise returns the same chord name that was passed inIntervals
getIntervals()
static Intervals
getIntervals(java.lang.String name)
int
getInversion()
static int
getInversionFromChordString(java.lang.String chordString)
Returns a count of the number of carets at the end of the chord string.Note[]
getNotes()
Pattern
getPattern()
Returns a patternPattern
getPatternWithNotes()
Pattern
getPatternWithNotesExceptBass()
Pattern
getPatternWithNotesExceptRoot()
Note
getRoot()
boolean
isMajor()
boolean
isMinor()
static boolean
isValidChord(java.lang.String candidateChordMusicString)
Returns true if the passed string contains a note, a known chord, and optionally an octave or duration.static void
putHumanReadable(java.lang.String chordName, java.lang.String humanReadableName)
static void
removeChord(java.lang.String name)
Chord
setBassNote(java.lang.String newBass)
Chord
setBassNote(Note newBass)
Although setBassNote takes a Note, it doesn't just set a local value to the incoming note.Chord
setInversion(int nth)
Chord
setOctave(int octave)
java.lang.String
toDebugString()
java.lang.String
toHumanReadableString()
java.lang.String
toNoteString()
Returns a string consisting of the notes in the chord.java.lang.String
toString()
-
-
-
Field Detail
-
chordMap
public static java.util.Map<java.lang.String,Intervals> chordMap
-
humanReadableMap
public static java.util.Map<java.lang.String,java.lang.String> humanReadableMap
-
MAJOR_INTERVALS
public static final Intervals MAJOR_INTERVALS
-
MINOR_INTERVALS
public static final Intervals MINOR_INTERVALS
-
DIMINISHED_INTERVALS
public static final Intervals DIMINISHED_INTERVALS
-
MAJOR_SEVENTH_INTERVALS
public static final Intervals MAJOR_SEVENTH_INTERVALS
-
MINOR_SEVENTH_INTERVALS
public static final Intervals MINOR_SEVENTH_INTERVALS
-
DIMINISHED_SEVENTH_INTERVALS
public static final Intervals DIMINISHED_SEVENTH_INTERVALS
-
MAJOR_SEVENTH_SIXTH_INTERVALS
public static final Intervals MAJOR_SEVENTH_SIXTH_INTERVALS
-
MINOR_SEVENTH_SIXTH_INTERVALS
public static final Intervals MINOR_SEVENTH_SIXTH_INTERVALS
-
-
Method Detail
-
getChordNames
public static java.lang.String[] getChordNames()
-
addChord
public static void addChord(java.lang.String name, java.lang.String intervalPattern)
-
addChord
public static void addChord(java.lang.String name, Intervals intervalPattern)
-
getIntervals
public static Intervals getIntervals(java.lang.String name)
-
removeChord
public static void removeChord(java.lang.String name)
-
getChordType
public static java.lang.String getChordType(Intervals intervals)
-
putHumanReadable
public static void putHumanReadable(java.lang.String chordName, java.lang.String humanReadableName)
-
getHumanReadableName
public static java.lang.String getHumanReadableName(java.lang.String chordName)
Returns a human readable chord name if one exists, otherwise returns the same chord name that was passed in
-
isValidChord
public static boolean isValidChord(java.lang.String candidateChordMusicString)
Returns true if the passed string contains a note, a known chord, and optionally an octave or duration.
-
fromNotes
public static Chord fromNotes(java.lang.String noteString)
-
fromNotes
public static Chord fromNotes(java.lang.String[] noteStrings)
-
getRoot
public Note getRoot()
-
getIntervals
public Intervals getIntervals()
-
getInversion
public int getInversion()
-
setInversion
public Chord setInversion(int nth)
-
setBassNote
public Chord setBassNote(java.lang.String newBass)
- See Also:
for details.
-
setBassNote
public Chord setBassNote(Note newBass)
Although setBassNote takes a Note, it doesn't just set a local value to the incoming note. Instead, it uses the incoming note to compute the inversion for this chord, and sets the inversion. getBassNote() reconstructs the bass note using the inversion. If the rootNote is null, this method returns without taking any action.
-
getBassNote
public Note getBassNote()
-
setOctave
public Chord setOctave(int octave)
-
getNotes
public Note[] getNotes()
-
getChordType
public java.lang.String getChordType()
-
getInversionFromChordString
public static int getInversionFromChordString(java.lang.String chordString)
Returns a count of the number of carets at the end of the chord string. Given Cmaj^^, this will return 2.
-
getPattern
public Pattern getPattern()
Description copied from interface:PatternProducer
Returns a pattern- Specified by:
getPattern
in interfacePatternProducer
-
getPatternWithNotes
public Pattern getPatternWithNotes()
-
getPatternWithNotesExceptRoot
public Pattern getPatternWithNotesExceptRoot()
-
getPatternWithNotesExceptBass
public Pattern getPatternWithNotesExceptBass()
-
isMajor
public boolean isMajor()
-
isMinor
public boolean isMinor()
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toNoteString
public java.lang.String toNoteString()
Returns a string consisting of the notes in the chord. For example, new Chord("Cmaj").toNoteString() returns "(C+E+G)" TODO: Update with Java 8 String Joiner
-
toHumanReadableString
public java.lang.String toHumanReadableString()
-
toDebugString
public java.lang.String toDebugString()
-
-