java.lang.Object
provided.abcMusic.utils.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#".
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
Nested ClassesModifier and TypeClassDescriptionprivate class
Utility class to keep track of the position of notes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static int[]
Half steps in a Major keyprivate static int[]
Half steps in a Minor keyprivate KeySignature.KeyNote[]
Special case for F# and D#mMap of sharps/flats in the key signatureprivate ILogger
logger to useprivate KeySignature.KeyNote[]
Ordering of notes (using only sharps) -
Constructor Summary
ConstructorsConstructorDescriptionKeySignature(String key)
Generate a "Key" object that enables easy access to the key signature. -
Method Summary
Modifier and TypeMethodDescriptionTakes a note and returns the properly transposed note in this key signatureprivate KeySignature.KeyNote
convertflat(char n)
Helper method to convert a note to its equivalent flat version.private void
Helper method to insert the given note into the keymap.private int
Takes a note (with no accidentals) and returns the accidental for this key signature.void
printmap()
Print the mapping for this key signature
-
Field Details
-
logger
logger to use -
_major
private static final int[] _majorHalf steps in a Major key -
_minor
private static final int[] _minorHalf steps in a Minor key -
keymap
Map of sharps/flats in the key signature -
notes
Ordering of notes (using only sharps) -
fs_dsm
Special case for F# and D#m
-
-
Constructor Details
-
KeySignature
Generate a "Key" object that enables easy access to the key signature.- Parameters:
key
- - String indicating key (i.e., "C" or "D#m")
-
-
Method Details
-
convertflat
Helper method to convert a note to its equivalent flat version.- Parameters:
n
- - note letter- Returns:
- - equivalent flat version of note n
-
insert
Helper method to insert the given note into the keymap.- Parameters:
n
- - note to add to the map
-
map
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
Takes a note and returns the properly transposed note in this key signature- Parameters:
n
- - note to be adjusted- Returns:
- A new, adjusted Note
-
printmap
public void printmap()Print the mapping for this key signature
-