|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jfugue.Parser
org.jfugue.MusicStringParser
public final class MusicStringParser
Parses music strings, and fires events for ParserListener
interfaces
when tokens are interpreted. The ParserListener
does intelligent things
with the resulting events, such as create music, draw sheet music, or
transform the data.
As of Version 3.0, the Parser supports turning MIDI Sequences into JFugue Patterns with the parse(Sequence)
method. In this case, the ParserListeners established by a ParserBuilder use the parsed
events to construct the Pattern string.
Field Summary |
---|
Fields inherited from class org.jfugue.Parser |
---|
listenerList, progressListenerList, TRACING_OFF, TRACING_ON |
Constructor Summary | |
---|---|
MusicStringParser()
Creates a new Parser object, and populates the dictionary with initial entries. |
Method Summary | |
---|---|
protected int |
getTempo()
Returns the tempo for the current song. |
boolean |
isValidToken(java.lang.String token)
Checks whether a token is valid. |
static void |
main(java.lang.String[] args)
Used for diagnostic purposes. |
void |
parse(Pattern pattern)
Parses a Pattern and fires events to subscribed ParserListener
interfaces. |
protected void |
setTempo(int tempo)
Sets the tempo for the current song. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MusicStringParser()
JFugueDefinitions
Method Detail |
---|
protected void setTempo(int tempo)
tempo
- the tempo for the current song, in pulses per quarter.protected int getTempo()
public void parse(Pattern pattern) throws JFugueException
Pattern
and fires events to subscribed ParserListener
interfaces. As the Pattern is parsed, events are sent
to ParserLisener
interfaces, which are responsible for doing
something interesting with the music data, such as playing the music,
displaying it as sheet music, or transforming the pattern.
The parser breaks a music string into tokens, which are separated by spaces. It then determines the type of command based on the first character of the token. If the parser does not recognize the first character of the token, which is limited to the command letters (K, V, T, I, L, X, #, $, @, &, +, *, |), the notes (A, B, C, D, E, F, G, R), and the open-bracket character ( [ ), then the token will be ignored.
pattern
- the Pattern
to parse
java.lang.Exception
- if there is an error parsing the pattern
JFugueException
public boolean isValidToken(java.lang.String token)
token
- the token to test for validity
true
is the token is valid; false
otherwise.public static void main(java.lang.String[] args)
args
- not used
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |