public class MidiExporter extends Exporter
This class is used to export the currently loaded MIDI sequence as a MIDI file.
Modifier and Type | Field and Description |
---|---|
private ExportResult |
exportResult |
private java.lang.String |
fileCharset
Source charset, specified in the sequence.
|
protected java.lang.String |
sourceCharset
(default) charset used to read the currently loaded file (or its text-based messages)
|
protected java.lang.String |
targetCharset
Target charset for text-based messages.
|
Constructor and Description |
---|
MidiExporter()
Creates a new MIDI exporter.
|
Modifier and Type | Method and Description |
---|---|
protected javax.sound.midi.Sequence |
cloneSequence()
Creates a modified copy of the loaded sequence.
|
private javax.sound.midi.MidiEvent |
convertCharset(javax.sound.midi.MidiEvent oldEvent,
java.lang.String text,
java.lang.String fileCharset,
int type,
long tick,
int trackNum)
Converts the text of a META message into the target charset.
|
ExportResult |
export(java.io.File file)
Exports a MIDI file.
|
protected java.lang.String |
getTargetCharset()
Determins and returns the target charset from the according charset combobox.
|
protected boolean |
mustIncludeRp026Tags()
Determins if RP-026 tags (charset switch or meta info) shall be included into the exported MIDI file or not.
|
private javax.sound.midi.MidiEvent |
removeCharsetSwitch(javax.sound.midi.MidiEvent oldEvent,
java.lang.String text,
int type,
long tick,
int trackNum)
Removes all charset switch tags from the event’s text.
|
createFile
protected java.lang.String sourceCharset
(default) charset used to read the currently loaded file (or its text-based messages)
protected java.lang.String targetCharset
Target charset for text-based messages.
private java.lang.String fileCharset
Source charset, specified in the sequence.
private ExportResult exportResult
public ExportResult export(java.io.File file) throws ExportException
Exports a MIDI file.
export
in class Exporter
file
- MIDI file.ExportException
- If the file can not be exported correctly.protected java.lang.String getTargetCharset()
Determins and returns the target charset from the according charset combobox.
Can be overridden to return a charset from a different combobox or a hard-coded value, depending on the format.
protected javax.sound.midi.Sequence cloneSequence() throws javax.sound.midi.InvalidMidiDataException
Creates a modified copy of the loaded sequence. Adds a meta event for the target charset. Removes meta events for all other charset switches. Removes meta events for key presses and key releases.
javax.sound.midi.InvalidMidiDataException
- if the new MIDI (copied) sequence cannot be created.protected boolean mustIncludeRp026Tags()
Determins if RP-026 tags (charset switch or meta info) shall be included into the exported MIDI file or not.
Returns true per default but can be overridden by a derived class.
private javax.sound.midi.MidiEvent convertCharset(javax.sound.midi.MidiEvent oldEvent, java.lang.String text, java.lang.String fileCharset, int type, long tick, int trackNum)
Converts the text of a META message into the target charset.
oldEvent
- The original MIDI event.text
- The text of the meta message.fileCharset
- Last charset, specified in the MIDI stream.type
- META message type.tick
- Tickstamp.trackNum
- Track number.private javax.sound.midi.MidiEvent removeCharsetSwitch(javax.sound.midi.MidiEvent oldEvent, java.lang.String text, int type, long tick, int trackNum)
Removes all charset switch tags from the event’s text.
oldEvent
- The original MIDI event.text
- The text of the meta message.type
- META message type.tick
- Tickstamp.trackNum
- Track number.