public class KernEventParser extends java.lang.Object implements EventParser
KernEventParser
parses notes in from a kern file.
Modifier and Type | Field and Description |
---|---|
private java.util.List<java.util.List<MidiNote>> |
goldStandard
The gold standard voices from this song.
|
private static java.util.regex.Pattern |
noteDurationPattern
A Regex pattern to grab a note duration from a **kern file.
|
private NoteEventParser |
noteEventParser
The NoteTracker which will keep track of the notes for this song.
|
private static java.util.regex.Pattern |
notePitchPattern
A Regex pattern to grab a note pitch from a **kern file.
|
private java.io.File |
song
The song we are parsing.
|
private TimeTracker |
timeTracker
The TimeTracker which will handle timing information for this song.
|
static int |
WHOLE_NOTE_DURATION_TICKS
The duration of a whole note, in ticks.
|
Constructor and Description |
---|
KernEventParser(java.io.File kernFile,
NoteEventParser noteEventParser,
TimeTracker timeTracker)
Creates a new KernEventParser
|
Modifier and Type | Method and Description |
---|---|
private int |
getDuration(int length,
int dotCount,
int lineNum)
Get the length in ticks of a note or rest with the given value and dots.
|
private int |
getDuration(java.lang.String voice,
int lineNum)
Get the duration, in ticks, of the given note or rest marker.
|
java.util.List<java.util.List<MidiNote>> |
getGoldStandardVoices()
Get a List of the gold standard voices from this song.
|
private int |
getOffsetAboveCFromChar(char pitch)
Get the offset (in semitones) above C of the given pitch.
|
private int |
getPitch(java.lang.String pitch)
Get the pitch number of the given note data.
|
private int |
getPitch(java.lang.String voice,
int lineNum)
Get the pitch of the given note or rest marker.
|
private void |
handleIndicator(java.lang.String indicator,
int lineNum)
Handle the given indicator read from the **kern file.
|
void |
run()
Parse the loaded file to the loaded NoteEventParser.
|
public static final int WHOLE_NOTE_DURATION_TICKS
private static final java.util.regex.Pattern noteDurationPattern
private static final java.util.regex.Pattern notePitchPattern
private TimeTracker timeTracker
private final NoteEventParser noteEventParser
private final java.io.File song
private java.util.List<java.util.List<MidiNote>> goldStandard
public KernEventParser(java.io.File kernFile, NoteEventParser noteEventParser, TimeTracker timeTracker)
kernFile
- The kern file we will parse.noteEventParser
- The NoteEventParser to pass events to when we run this parser.timeTracker
- timeTracker
public void run() throws java.io.IOException
run
in interface EventParser
java.io.IOException
- If an I/O error occurred while reading the file.private int getDuration(java.lang.String voice, int lineNum) throws java.io.IOException
voice
- A note or rest marker.lineNum
- The line number the note or rest marker came from.java.io.IOException
- If no duration is found.private int getDuration(int length, int dotCount, int lineNum)
length
- The value of the note, in **kern format. 1 = whole note, 2 = half note, etc.dotCount
- The number of dots after the note.lineNum
- The line number this duration was found on.private int getPitch(java.lang.String voice, int lineNum) throws java.io.IOException
voice
- A note or rest marker.lineNum
- The line number the note or rest marker came from.java.io.IOException
- If no rest or pitch is found.private int getPitch(java.lang.String pitch)
pitch
- The **kern pitch String.private void handleIndicator(java.lang.String indicator, int lineNum) throws java.io.IOException
indicator
- The indicator we need to parse.lineNum
- The line number the indicator came from.java.io.IOException
- If some error occurred in parsing the indicator.private int getOffsetAboveCFromChar(char pitch)
pitch
- The pitch character we want the offset above C for.public java.util.List<java.util.List<MidiNote>> getGoldStandardVoices()
getGoldStandardVoices
in interface EventParser