util
Class KeySignature

java.lang.Object
  extended by util.KeySignature

public class KeySignature
extends java.lang.Object

Utility class to simplify dealing with key signatures


Nested Class Summary
private  class KeySignature.KeyNote
          Utility class to keep track of the position of notes
 
Field Summary
private static int[] _major
          Half steps in a Major key
private static int[] _minor
          Half steps in a Minor key
private  java.util.Map<java.lang.Character,java.lang.Integer> keymap
          Map of sharps/flats in the key signature
private  KeySignature.KeyNote[] notes
          Ordering of notes (using only sharps)
 
Constructor Summary
KeySignature(java.lang.String key)
          Generate a "Key" object that enables easy access to the key signature.
 
Method Summary
 Note adjust(Note n)
          Takes a note and returns the properly transposed note in this key signature
private  int map(java.lang.Character note)
          Takes a note (with no accidentals) and returns the accidental for this key signature.
 void printmap()
          Print the mapping for this key signature
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_major

private static int[] _major
Half steps in a Major key


_minor

private static int[] _minor
Half steps in a Minor key


keymap

private java.util.Map<java.lang.Character,java.lang.Integer> keymap
Map of sharps/flats in the key signature


notes

private KeySignature.KeyNote[] notes
Ordering of notes (using only sharps)

Constructor Detail

KeySignature

public KeySignature(java.lang.String key)
Generate a "Key" object that enables easy access to the key signature.

Parameters:
key - - String indicating key (i.e., "C" or "D#m")
Method Detail

map

private int map(java.lang.Character note)
Takes a note (with no accidentals) and returns the accidental for this key signature.

Parameters:
note - - in [A, B, C, D, E, F, G]
Returns:
accidental for the note in this key signature [-1, 0, 1]

adjust

public Note adjust(Note n)
Takes a note and returns the properly transposed note in this key signature

Parameters:
n - - note to be adjusted

printmap

public void printmap()
Print the mapping for this key signature