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>chordMapstatic IntervalsDIMINISHED_INTERVALSstatic IntervalsDIMINISHED_SEVENTH_INTERVALSstatic java.util.Map<java.lang.String,java.lang.String>humanReadableMapstatic IntervalsMAJOR_INTERVALSstatic IntervalsMAJOR_SEVENTH_INTERVALSstatic IntervalsMAJOR_SEVENTH_SIXTH_INTERVALSstatic IntervalsMINOR_INTERVALSstatic IntervalsMINOR_SEVENTH_INTERVALSstatic IntervalsMINOR_SEVENTH_SIXTH_INTERVALS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddChord(java.lang.String name, java.lang.String intervalPattern)static voidaddChord(java.lang.String name, Intervals intervalPattern)booleanequals(java.lang.Object o)static ChordfromNotes(java.lang.String noteString)static ChordfromNotes(java.lang.String[] noteStrings)static ChordfromNotes(Note[] notes)NotegetBassNote()static java.lang.String[]getChordNames()java.lang.StringgetChordType()static java.lang.StringgetChordType(Intervals intervals)static java.lang.StringgetHumanReadableName(java.lang.String chordName)Returns a human readable chord name if one exists, otherwise returns the same chord name that was passed inIntervalsgetIntervals()static IntervalsgetIntervals(java.lang.String name)intgetInversion()static intgetInversionFromChordString(java.lang.String chordString)Returns a count of the number of carets at the end of the chord string.Note[]getNotes()PatterngetPattern()Returns a patternPatterngetPatternWithNotes()PatterngetPatternWithNotesExceptBass()PatterngetPatternWithNotesExceptRoot()NotegetRoot()booleanisMajor()booleanisMinor()static booleanisValidChord(java.lang.String candidateChordMusicString)Returns true if the passed string contains a note, a known chord, and optionally an octave or duration.static voidputHumanReadable(java.lang.String chordName, java.lang.String humanReadableName)static voidremoveChord(java.lang.String name)ChordsetBassNote(java.lang.String newBass)ChordsetBassNote(Note newBass)Although setBassNote takes a Note, it doesn't just set a local value to the incoming note.ChordsetInversion(int nth)ChordsetOctave(int octave)java.lang.StringtoDebugString()java.lang.StringtoHumanReadableString()java.lang.StringtoNoteString()Returns a string consisting of the notes in the chord.java.lang.StringtoString()
-
-
-
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:PatternProducerReturns a pattern- Specified by:
getPatternin 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:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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()
-
-