|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprovided.abcParser.ABCParser
public class ABCParser
Parses an abc file into IPhrase music structures
Usage:
ABCParser parser = new ABCParser("/data/aMusicFile.abc");
IPhrase phrase = parser.parse();
Cases handled:
- single notes with and without accidentals and naturals with regards to measures
- chords
- dotted notes
- grace notes
- repeats, including first and second repeats.
- triplets
- tuplets
- all headers
- quoted text
- D.C. al fine
- EOF (End Of File)
All other cases ignored.
Field Summary | |
---|---|
private ABCTokenizer |
abcT
ABCTokenizer to use. |
private java.util.Set<Note> |
accidentalNotes
Set of accidental notes in the current measure. |
private DecoratorSeqList |
beginningTarget
Proxy to that is used to reference the beginning of the phrase before it has finished being calculated. |
private ATokVisitor |
checkNextNoteAlgo
Checks for dotted notes. |
private double |
dottedCorrection
The amount to additively correct the duration by due to dotted notes; |
(package private) double |
grace_multiplier
Grace note duration multiplier. |
(package private) double |
graceDuration
Total grace note duration of previous grace notes |
private boolean |
isGrace
Current notes to be parsed are grace notes |
private java.util.Stack<DecoratorSeqList> |
jumpSecondRepeatStack
Stack that holds the proxies to the current second repeat start location. |
private java.util.Stack<DecoratorSeqList> |
jumpTargetStack
A stack that hold the latest jump targets (repeat start) for repeats. |
private ATokVisitor |
makeSeqListAlgo
Main algo used to create a list of IPhrases from the stream of tokens that represents the progression of the song (phrase). |
Constructor Summary | |
---|---|
ABCParser(java.lang.String inputFileName)
Constructs a parser for the given ABC input file. |
Method Summary | |
---|---|
private void |
addAccidental(Note note)
Adds a note to the set of accidentals replaces any note with the same name and octave. |
private void |
checkAccidentals(Note note)
Checks to see if the given Note is in the set of accidentals Checks name and octave but not duration or accidental |
private Note |
makeNote(Token host)
Parse a Note from the given Token |
IPhrase |
parse()
Run the parser and parse the entire file, returning an IPhrase object that represents the entire piece of music. |
private DecoratorSeqList |
popJumpTarget()
Pull off the current jump target from the jump target stack. |
private void |
pushJumpTarget(DecoratorSeqList target)
Push the given jump target onto the stack so that it is now the current jump target. |
private void |
removeAccidental(Note note)
Removes a note from the set of accidentals Removes any note with the same name and octave. |
private Token |
swapToken(Token t)
Swap the given token for the next token in the tokenizer, returning the next token. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private ABCTokenizer abcT
private DecoratorSeqList beginningTarget
private java.util.Stack<DecoratorSeqList> jumpTargetStack
private java.util.Stack<DecoratorSeqList> jumpSecondRepeatStack
private ATokVisitor makeSeqListAlgo
private boolean isGrace
double grace_multiplier
double graceDuration
private double dottedCorrection
private ATokVisitor checkNextNoteAlgo
private java.util.Set<Note> accidentalNotes
Constructor Detail |
---|
public ABCParser(java.lang.String inputFileName)
inputFileName
- the name of the input text fileMethod Detail |
---|
private DecoratorSeqList popJumpTarget()
private void pushJumpTarget(DecoratorSeqList target)
target
- The new current jump target.public IPhrase parse()
private Note makeNote(Token host)
host
- The Note token
private void checkAccidentals(Note note)
note
- The note to checkprivate void addAccidental(Note note)
note
- the Note to add.private void removeAccidental(Note note)
note
- the note to removeprivate Token swapToken(Token t)
t
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |