|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprovided.util.KeySignature
public class KeySignature
Utility class to simplify dealing with key signatures
Usage:
KeySignature keySig = new KeySignature(aKey); // aKey is a string representing a key, e.g. "C", "Bb", "Am"
Note adjustedNote = keySig.adjust(originalNote); // returns the Note object, adjusted so that it matches the key,
e.g for key of "D", an "F" --> "F#".
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 KeySignature.KeyNote[] |
fs_dsm
Special case for F# and D#m |
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 KeySignature.KeyNote |
convertflat(char n)
Helper method to convert a note to its equivalent flat version. |
private void |
insert(KeySignature.KeyNote n)
Helper method to insert the given note into the keymap. |
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 |
---|
private static final int[] _major
private static final int[] _minor
private java.util.Map<java.lang.Character,java.lang.Integer> keymap
private KeySignature.KeyNote[] notes
private KeySignature.KeyNote[] fs_dsm
Constructor Detail |
---|
public KeySignature(java.lang.String key)
key
- - String indicating key (i.e., "C" or "D#m")Method Detail |
---|
private KeySignature.KeyNote convertflat(char n)
n
- - note letter
private void insert(KeySignature.KeyNote n)
n
- - note to add to the mapprivate int map(java.lang.Character note)
note
- - in [A, B, C, D, E, F, G]
public Note adjust(Note n)
n
- - note to be adjustedpublic void printmap()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |