|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.soundhelix.misc.Chord
public class Chord
Defines a chord. A chord is immutable and consists of 3 different pitches, which cannot span more than 11 halftones. A chord may be one of the common type major, minor, diminished or augmented (all of them in all three inversion flavors) or can have any other pitch combination. All chords can be rotated up or down. Rotating a chord up means replacing the chord's low pitch with the same pitch transposed one octave up. Rotating a chord down means replacing the chord's high pitch with the same pitch transposed one octave down. All common type chords (except for augmented chords) can be normalized, which means that the chords are rotated up or down so that their low pitch equals the root pitch of the chord (e.g., "C4" and "C6" are normalized to "C"), if that is not already the case. Augmented chords cannot be normalized, because they don't have a unique root pitch (e.g., the chords "Caug", "Eaug6" and "G#aug4" are not distinguishable if you look at their pitches).
| Constructor Summary | |
|---|---|
Chord(int pitch1,
int pitch2,
int pitch3)
Instantiates a chord. |
|
| Method Summary | |
|---|---|
boolean |
containsPitch(int pitch)
Returns true if the given pitch is a note that is contained in the chord, false otherwise. |
boolean |
equals(Object other)
Implements an equality check. |
boolean |
equalsNormalized(Object other)
Implements an equality check. |
Chord |
findChordClosestTo(Chord otherChord)
Returns a chord that is a rotated version of this chord whose middle pitch is as close to the middle pitch of the given other chord as possible. |
int |
getHighPitch()
Returns the pitch of the high note of the chord. |
int |
getLowPitch()
Returns the pitch of the low note of the chord. |
int |
getMiddlePitch()
Returns the pitch of the middle note of the chord. |
int |
getPitch(int offset)
Returns the pitch of the given chord offset. 0 will return the low pitch, 1 the middle pitch, 2 the high pitch, 3 the low pitch transposed up by 1 octave, etc. |
int |
hashCode()
|
boolean |
isAugmented()
Returns true iff this chord is an augmented chord. |
boolean |
isDiminished()
Returns true iff this chord is a diminished chord. |
boolean |
isMajor()
Returns true iff this chord is a major chord. |
boolean |
isMajor7()
Returns true iff this chord is a major7 chord. |
boolean |
isMinor()
Returns true iff this chord is a minor chord. |
boolean |
isMinor7()
Returns true iff this chord is a minor7 chord. |
Chord |
normalize()
Normalizes the chord. |
static Chord |
parseChord(String chordString,
int crossoverPitch)
Parses the given chord string and returns a Chord instance that represents the chord string. |
Chord |
rotateDown()
Rotates the chord down by one chord offset. |
Chord |
rotateUp()
Rotates the chord up by one chord offset. |
String |
toString()
Returns a string representation of this chord. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Chord(int pitch1,
int pitch2,
int pitch3)
pitch1 - the first pitchpitch2 - the second pitchpitch3 - the third pitch| Method Detail |
|---|
public boolean isMajor()
public boolean isMajor7()
public boolean isMinor()
public boolean isMinor7()
public boolean isDiminished()
public boolean isAugmented()
public boolean equals(Object other)
equals in class Objectother - the other chord to compare this chord to
public boolean equalsNormalized(Object other)
other - the other chord to compare this chord to
public String toString()
toString in class Objectpublic int getLowPitch()
public int getMiddlePitch()
public int getHighPitch()
public int getPitch(int offset)
offset - the chord offset
public Chord normalize()
public Chord rotateUp()
public Chord rotateDown()
public boolean containsPitch(int pitch)
pitch - the pitch
public Chord findChordClosestTo(Chord otherChord)
otherChord - the other chord
public int hashCode()
hashCode in class Object
public static Chord parseChord(String chordString,
int crossoverPitch)
chordString - the chord as a stringcrossoverPitch - the crossover pitch (between 1 and 12)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||