public class KeySignature
extends java.lang.Object
KeySignature
stores the key signature of a song. That is, the key (represented by the
number of sharps in its signature), and whether it is major or minor.Modifier and Type | Field and Description |
---|---|
private boolean |
major
True if this key is major.
|
private int |
numSharps
The number of sharps in this key signature.
|
Constructor and Description |
---|
KeySignature()
Create a default key signature (C major).
|
KeySignature(byte[] data)
Create a new Key Signature based on the given data array.
|
KeySignature(int keyNumber,
boolean isMajor)
Create a new key signature based on the given key number and major boolean.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other) |
int |
getNumSharps()
Get the number of sharps in this key signature.
|
int |
getPositiveOffsetFromC()
Get the positive offset from C of the tonic note of this key.
|
int |
hashCode() |
boolean |
isMajor()
Return whether this key is major or not.
|
java.lang.String |
toString() |
private final int numSharps
private final boolean major
public KeySignature()
public KeySignature(byte[] data)
data
- data[0] is numSharps. data[1] is 0 for major, 1 for minor.public KeySignature(int keyNumber, boolean isMajor)
keyNumber
- The positive offset from c to this key's tonic note.isMajor
- major
public int getPositiveOffsetFromC()
public int getNumSharps()
numSharps
public boolean isMajor()
major
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object