xhtml.startDocument();
// MidiSystem expects the stream to support the mark feature
InputStream buffered = new BufferedInputStream(stream);
try {
Sequence sequence = MidiSystem.getSequence(buffered);
Track[] tracks = sequence.getTracks();
metadata.set("tracks", String.valueOf(tracks.length));
Patch[] patches = sequence.getPatchList();
metadata.set("patches", String.valueOf(patches.length));
float type = sequence.getDivisionType();
if (type == Sequence.PPQ) {
metadata.set("divisionType", "PPQ");
} else if (type == Sequence.SMPTE_24) {
metadata.set("divisionType", "SMPTE_24");
} else if (type == Sequence.SMPTE_25) {