abc.notation
Class KeySignature

java.lang.Object
  extended byabc.notation.KeySignature
All Implemented Interfaces:
ScoreElementInterface

public class KeySignature
extends java.lang.Object
implements ScoreElementInterface

This class defines key signatures using modes definition like E major, G minor etc etc...

                           1   2   3   4   5   6   7
 Major (Ionian, mode 1)    D   E   F#  G   A   B   C#
 Dorian (mode 2)               E   F#  G   A   B   C#   D
 Mixolydian (mode 5)                       A   B   C#   D   E   F#  G
 Aeolian (mode 6)                              B   C#   D   E   F#  G   A
 
If we consider the key namned "Ab aeolian", "A" is called the note of this key, "b" is called the key accidental and "aeolian" is called the mode.


Field Summary
static byte AEOLIAN
          The aeolian mode type.
static byte DORIAN
          The dorian mode type.
static byte IONIAN
          The ionian mode type.
static byte LOCRIAN
          The locrian mode type.
static byte LYDIAN
          The lydian mode type.
static byte MAJOR
          The major mode type.
static byte MINOR
          The minor mode type.
static byte MIXOLYDIAN
          The mixolydian mode type.
static byte OTHER
          The "not standard" mode type.
static byte PHRYGIAN
          The phrygian mode type.
 
Constructor Summary
KeySignature(byte[] accidentalsDefinition)
          Creates a key signature with the specified accidentals.
KeySignature(byte keyNoteType, byte modeType)
          Creates a new signature with the specified parameters.
KeySignature(byte keyNoteType, byte keyAccidental, byte modeType)
          Creates a new signature with the specified parameters.
 
Method Summary
static byte convertToAccidentalType(java.lang.String accidental)
           
static byte convertToModeType(java.lang.String mode)
           
 byte getAccidental()
          Returns key accidental for this Key.
 byte getAccidentalFor(byte noteHeigth)
          Returns accidental for the specified note heigth for this key.
 byte[] getAccidentals()
          Returns accidentals of this key signature.
 byte getMode()
          Returns the mode of this key.
 byte getNote()
          Returns the note of the mode.
 void setAccidental(byte noteHeigth, byte accidental)
          Sets the accidental for the specified note.
 java.lang.String toLitteralNotation()
           
 java.lang.String toString()
          Returns a String representation of this key.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AEOLIAN

public static final byte AEOLIAN
The aeolian mode type.

See Also:
Constant Field Values

DORIAN

public static final byte DORIAN
The dorian mode type.

See Also:
Constant Field Values

IONIAN

public static final byte IONIAN
The ionian mode type.

See Also:
Constant Field Values

LOCRIAN

public static final byte LOCRIAN
The locrian mode type.

See Also:
Constant Field Values

LYDIAN

public static final byte LYDIAN
The lydian mode type.

See Also:
Constant Field Values

MAJOR

public static final byte MAJOR
The major mode type.

See Also:
Constant Field Values

MINOR

public static final byte MINOR
The minor mode type.

See Also:
Constant Field Values

MIXOLYDIAN

public static final byte MIXOLYDIAN
The mixolydian mode type.

See Also:
Constant Field Values

PHRYGIAN

public static final byte PHRYGIAN
The phrygian mode type.

See Also:
Constant Field Values

OTHER

public static final byte OTHER
The "not standard" mode type.

See Also:
Constant Field Values
Constructor Detail

KeySignature

public KeySignature(byte keyNoteType,
                    byte modeType)
Creates a new signature with the specified parameters.

Parameters:
keyNoteType - The note of the mode. Possible values are Note.A, Note.B, Note.C, Note.D, Note.E, Note.F or Note.G.
modeType - The type of the mode. Possible values are AEOLIAN, DORIAN, IONIAN, LOCRIAN, LYDIAN MAJOR, MINOR, MIXOLYDIAN, PHRYGIAN or OTHER.

KeySignature

public KeySignature(byte keyNoteType,
                    byte keyAccidental,
                    byte modeType)
Creates a new signature with the specified parameters.

Parameters:
keyNoteType - The note of the mode. Possible values are Note.A, Note.B, Note.C, Note.D, Note.E, Note.F or Note.G.
keyAccidental - Accidental for the note mode. Possible values are AccidentalType.SHARP, AccidentalType.NATURAL? AccidentalType.NONE, or AccidentalType.FLAT.
modeType - The type of the mode. Possible values are AEOLIAN, DORIAN, IONIAN, LOCRIAN, LYDIAN, MAJOR, MINOR, MIXOLYDIAN, PHRYGIAN or OTHER.
Throws:
java.lang.IllegalArgumentException - Thrown if keyAccidental or modeType are out of the allowed values.

KeySignature

public KeySignature(byte[] accidentalsDefinition)
Creates a key signature with the specified accidentals.

Parameters:
accidentalsDefinition - Accidental definition from note C to B. Possible values for accidentals are : AccidentalType.SHARP, AccidentalType.NATURAL or AccidentalType.FLAT.
Method Detail

getNote

public byte getNote()
Returns the note of the mode.

Returns:
The note of the mode. Possible values are Note.A, Note.B, Note.C, Note.D, Note.E, Note.F or Note.G.

getMode

public byte getMode()
Returns the mode of this key.

Returns:
The mode of this key. Possible values are AEOLIAN, DORIAN, IONIAN, LOCRIAN, LYDIAN, MAJOR, MINOR, MIXOLYDIAN, PHRYGIAN or OTHER.

getAccidental

public byte getAccidental()
Returns key accidental for this Key.

Returns:
This key's key accidental. Ex: for "Ab aeolian", the key accidental is "b" (flat)

getAccidentals

public byte[] getAccidentals()
Returns accidentals of this key signature.

Returns:
accidentals of this key signature

setAccidental

public void setAccidental(byte noteHeigth,
                          byte accidental)
                   throws java.lang.IllegalArgumentException
Sets the accidental for the specified note.

Parameters:
noteHeigth - The note heigth. Possible values are, Note.A, Note.B, Note.C, Note.D, Note.E, Note.F or Note.G.
accidental - The accidental to be set to the note. Possible values are : AccidentalType.SHARP, AccidentalType.NATURAL or AccidentalType.FLAT.
Throws:
java.lang.IllegalArgumentException - Thrown if an invalid note heigth or accidental has been given.

getAccidentalFor

public byte getAccidentalFor(byte noteHeigth)
Returns accidental for the specified note heigth for this key.

Parameters:
noteHeigth - A note heigth among Note.C, Note.D, Note.E, Note.F, Note.G, Note.A, Note.B.
Returns:
Accidental value for the specified note heigth. This value can be NATURAL, FLAT or SHARP.
Throws:
java.lang.IllegalArgumentException - Thrown if the specified note heigth is invalid.

toLitteralNotation

public java.lang.String toLitteralNotation()

convertToModeType

public static byte convertToModeType(java.lang.String mode)

convertToAccidentalType

public static byte convertToAccidentalType(java.lang.String accidental)
                                    throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

toString

public java.lang.String toString()
Returns a String representation of this key.

Returns:
A String representation of this key.