public abstract class SequenceParser extends java.lang.Object implements IParser
This class can be extended by specialized parser classes which parse an input file and create a MIDI sequence.
Derived classes are:
MidicaPLParser
(parses a MidicaPL file)MidiParser
(parses a MIDI file)MidiParser
(use an external tool to create a temporary midi file and parse this file)Modifier and Type | Field and Description |
---|---|
private static java.io.File |
currentFile
The file to be parsed.
|
private static java.io.File |
sequenceFile
Last successfully parsed file.
|
protected static byte |
transposeLevel
Defines how much the parsed input has to be transposed.
|
Constructor and Description |
---|
SequenceParser() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getFileName()
Returns the base name of the successfully parsed file.
|
static java.lang.String |
getFilePath()
Returns the absolute path of the successfully parsed file.
|
static byte |
getTransposeLevel()
Returns the transpose level.
|
protected void |
postprocessSequence(javax.sound.midi.Sequence seq,
java.lang.String charset)
Postprocesses the loaded MIDI sequence.
|
protected void |
preprocess(java.io.File file)
Resets the file name and format.
|
static void |
setTransposeLevel(byte level)
Sets the transpose level.
|
protected int |
transpose(int note,
int channel)
Transposes the given note into another pitch according to the current
transposeLevel . |
protected static byte transposeLevel
Defines how much the parsed input has to be transposed. A positive transpose level causes a transposition into higher pitches. A negative level transposes into lower pitches.
private static java.io.File sequenceFile
Last successfully parsed file.
private static java.io.File currentFile
The file to be parsed.
public static byte getTransposeLevel()
Returns the transpose level. This is the value which defines how much the input has to be transposed before creating the MIDI stream.
public static void setTransposeLevel(byte level)
Sets the transpose level. That defines how much the parsed input is transposed.
level
- Transpose levelprotected int transpose(int note, int channel) throws ParseException
Transposes the given note into another pitch according to the current transposeLevel
. Does not transpose anything on channel 9 because that is the percussion channel and transposing percussion instrument transposition is not supported.
note
- Input note value as defined by the MIDI specification (0-127)channel
- Channel number as defined by the MIDI specification (0-15)ParseException
- If the transposition would cause an invalid target note with a value lower than 0 or higher than 127.protected void preprocess(java.io.File file)
Resets the file name and format. Remembers the file to be parsed so that it can be marked as successful later.
This method is called before parsing.
file
- The file to be parsed.protected void postprocessSequence(javax.sound.midi.Sequence seq, java.lang.String charset) throws ParseException
Postprocesses the loaded MIDI sequence.
Retrieves information from the given sequence and makes it available for the InfoView
.
Makes the created sequence available for the player.
The sequence to be analyzed is not necessarily the same that will be published. After parsing a MidicaPL file it’s the same. But after parsing a MIDI file the original sequence will be analyzed while the sequence created by the SequenceCreator
will be published.
seq
- The MIDI sequence to be analyzed.charset
- The charset that has been chosen in the file chooser (or assumed).ParseException
- if a marker event cannot be created during the postprocessing of the analyzing processpublic static java.lang.String getFilePath()
Returns the absolute path of the successfully parsed file. Returns null, if no file has been parsed successfully.
public static java.lang.String getFileName()
Returns the base name of the successfully parsed file.