public class Chord extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Chord.InversionType
The chord inversion type.
|
Constructor and Description |
---|
Chord(int pitch1,
int pitch2,
int pitch3)
Instantiates a chord.
|
Modifier and Type | Method and Description |
---|---|
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() |
Chord |
normalize()
Returns a normalized version of 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.
|
public Chord(int pitch1, int pitch2, int pitch3)
pitch1
- the first pitchpitch2
- the second pitchpitch3
- the third pitchpublic boolean equals(Object other)
public boolean equalsNormalized(Object other)
other
- the other chord to compare this chord topublic String toString()
public int getLowPitch()
public int getMiddlePitch()
public int getHighPitch()
public int getPitch(int offset)
offset
- the chord offsetpublic Chord normalize()
public Chord rotateUp()
public Chord rotateDown()
public boolean containsPitch(int pitch)
pitch
- the pitchpublic Chord findChordClosestTo(Chord otherChord)
otherChord
- the other chord