Class SignatureSubparser
java.lang.Object
org.staccato.SignatureSubparser
- All Implemented Interfaces:
KeyProvider, Subparser
Parses both Instrument and Layer tokens. Each has values that are parsed as bytes.
- Author:
- dkoelle
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyteconvertAccidentalCountToKeyRootPositionInOctave(int accidentalCount, byte scale) Turns number of accidentals (negative for flats, positive for sharps) to a key and returns the key's root note's position in the octavebyteconvertKeyToByte(Key key) Converts the given Key to a byte value, from -7 for Cb major or Ab major to +7 for C# minor or A# minor, with 0 being C major or A minorGiven a key signature, like "Cmaj" or "Kbbbb", return the corresponding KeycreateKeyFromAccidentals(String keySignature) Returns a Key given a string containing as many flats or sharps as the number one would see on a staff for the corresponding key; e.g., "Kbbbb" = Ab MajorcreateKeyString(byte notePositionInOctave, byte scale) Creates a key name, like Cmaj, given the root note's position in an octave (e.g., 0 for C) and a major or minor indicator - @see Scale MAJOR_SCALE_INDICATOR and MINOR_SCALE_INDICATORstatic SignatureSubparsergetTokenType(String tokenString) Asks the subparser to provide a TokenType for the given token.booleanIndicates whether the subparser should be responsible for parsing the given music string.booleanmatchesKeySignature(String music) booleanmatchesTimeSignature(String music) intparse(String music, StaccatoParserContext context) Parses the given music string.
-
Field Details
-
KEY_SIGNATURE
- See Also:
-
TIME_SIGNATURE
- See Also:
-
SEPARATOR
- See Also:
-
MAJOR_KEY_SIGNATURES
-
MINOR_KEY_SIGNATURES
-
KEYSIG_MIDPOINT
public static final int KEYSIG_MIDPOINT- See Also:
-
MAJOR_ABBR
- See Also:
-
MINOR_ABBR
- See Also:
-
SHARP_CHAR
public static final char SHARP_CHAR- See Also:
-
FLAT_CHAR
public static final char FLAT_CHAR- See Also:
-
-
Constructor Details
-
SignatureSubparser
public SignatureSubparser()
-
-
Method Details
-
getInstance
-
matches
Description copied from interface:SubparserIndicates whether the subparser should be responsible for parsing the given music string. -
matchesKeySignature
-
matchesTimeSignature
-
getTokenType
Description copied from interface:SubparserAsks the subparser to provide a TokenType for the given token.- Specified by:
getTokenTypein interfaceSubparser- Parameters:
tokenString- The Staccato token to map to a type
-
parse
Description copied from interface:SubparserParses the given music string. -
createKey
Description copied from interface:KeyProviderGiven a key signature, like "Cmaj" or "Kbbbb", return the corresponding Key- Specified by:
createKeyin interfaceKeyProvider
-
createKeyFromAccidentals
-
createKeyString
Description copied from interface:KeyProviderCreates a key name, like Cmaj, given the root note's position in an octave (e.g., 0 for C) and a major or minor indicator - @see Scale MAJOR_SCALE_INDICATOR and MINOR_SCALE_INDICATOR- Specified by:
createKeyStringin interfaceKeyProvider
-
convertAccidentalCountToKeyRootPositionInOctave
public byte convertAccidentalCountToKeyRootPositionInOctave(int accidentalCount, byte scale) Description copied from interface:KeyProviderTurns number of accidentals (negative for flats, positive for sharps) to a key and returns the key's root note's position in the octave- Specified by:
convertAccidentalCountToKeyRootPositionInOctavein interfaceKeyProvider
-
convertKeyToByte
Description copied from interface:KeyProviderConverts the given Key to a byte value, from -7 for Cb major or Ab major to +7 for C# minor or A# minor, with 0 being C major or A minor- Specified by:
convertKeyToBytein interfaceKeyProvider
-