I'm working on a personal project in Java and I'm using JFugue to simplify music generation and playback. I'm trying to output a MusicXML file for each of my saved MIDI files so They can be viewed in Finale NotePad, but the MusicXML files that are output don't seem to be properly formatted. They end abruptly like so: "...<type>/0.0</type></note><note><".
Here is the code I'm using to write the files:
System.out.print("Enter name of MIDI file: ");
String midi = scan.next();
try
{
Pattern pat = player.loadMidi(new File(midi + ".mid"));
MidiParser parser = new MidiParser();
MusicXmlRenderer renderer = new MusicXmlRenderer();
FileWriter writer = new FileWriter(midi + ".xml");
parser.addParserListener(renderer);
parser.parse(player.getSequence(pat));
writer.write(renderer.getMusicXMLString());
writer.close();
}
catch(InvalidMidiDataException e)
{
System.out.println(e.toString());
}
catch(IOException e)
{
System.out.println(e.toString());
}