public class KeySignature
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
KeySignature.KeyNote
Utility class to keep track of the position of notes
|
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
KeySignature(java.lang.String key)
Generate a "Key" object that enables easy access to the key signature.
|
Modifier and Type | Method and Description |
---|---|
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
|
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
public KeySignature(java.lang.String key)
key
- - String indicating key (i.e., "C" or "D#m")private KeySignature.KeyNote convertflat(char n)
n
- - note letterprivate 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()