Package org.staccato
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 TypeMethodDescriptionbyte
convertAccidentalCountToKeyRootPositionInOctave
(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 octavebyte
convertKeyToByte
(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 SignatureSubparser
getTokenType
(String tokenString) Asks the subparser to provide a TokenType for the given token.boolean
Indicates whether the subparser should be responsible for parsing the given music string.boolean
matchesKeySignature
(String music) boolean
matchesTimeSignature
(String music) int
parse
(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:Subparser
Indicates whether the subparser should be responsible for parsing the given music string. -
matchesKeySignature
-
matchesTimeSignature
-
getTokenType
Description copied from interface:Subparser
Asks the subparser to provide a TokenType for the given token.- Specified by:
getTokenType
in interfaceSubparser
- Parameters:
tokenString
- The Staccato token to map to a type
-
parse
Description copied from interface:Subparser
Parses the given music string. -
createKey
Description copied from interface:KeyProvider
Given a key signature, like "Cmaj" or "Kbbbb", return the corresponding Key- Specified by:
createKey
in interfaceKeyProvider
-
createKeyFromAccidentals
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 Major -
createKeyString
Description copied from interface:KeyProvider
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_INDICATOR- Specified by:
createKeyString
in interfaceKeyProvider
-
convertAccidentalCountToKeyRootPositionInOctave
public byte convertAccidentalCountToKeyRootPositionInOctave(int accidentalCount, byte scale) Description copied from interface:KeyProvider
Turns 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:
convertAccidentalCountToKeyRootPositionInOctave
in interfaceKeyProvider
-
convertKeyToByte
Description copied from interface:KeyProvider
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 minor- Specified by:
convertKeyToByte
in interfaceKeyProvider
-