use of com.xenoage.zong.musicxml.types.MxlScorePartwise in project Zong by Xenoage.
the class MusicXmlScoreFileInput method read.
/**
* Creates a {@link Score} instance from the document
* behind the given {@link InputStream}.
* @param inputStream the input stream with the MusicXML document
* @param filePath file path if known, null otherwise
*/
@Override
public Score read(InputStream stream, @MaybeNull String filePath) throws InvalidFormatException, IOException {
// parse MusicXML file
MxlScorePartwise score;
try {
XmlReader xmlReader = platformUtils().createXmlReader(stream);
MusicXMLDocument doc = MusicXMLDocument.read(xmlReader);
score = doc.getScore();
} catch (XmlDataException ex) {
// no valid MusicXML
throw new InvalidFormatException(ex);
} catch (Exception ex) {
throw new IOException(ex);
}
return read(score, Level.LogErrors);
}
use of com.xenoage.zong.musicxml.types.MxlScorePartwise in project Zong by Xenoage.
the class MusicXmlScoreDocFileReader method read.
public Promise<ScoreDoc> read() {
return new Promise<>(ret -> {
MusicXmlFileReader reader = new MusicXmlFileReader(stream, filePath, new AllFilter<>());
reader.produce(new AsyncResult<List<Score>>() {
@Override
public void onSuccess(List<Score> scores) {
if (scores.size() == 0) {
// no score was opened
ret.resolve(null);
} else {
// open first selected score
Score score = scores.get(0);
ScoreDoc scoreDoc;
try {
scoreDoc = new ScoreDocFactory().read(score);
// add credit elements - TIDY
Object o = score.getMetaData().get("mxldoc");
if (o != null && o instanceof MxlScorePartwise) {
MxlScorePartwise doc = (MxlScorePartwise) o;
CreditsReader.read(doc, scoreDoc.getLayout(), score.getFormat());
}
ret.resolve(scoreDoc);
} catch (Exception ex) {
ret.reject(ex);
}
}
}
@Override
public void onFailure(Exception ex) {
ret.reject(ex);
}
});
});
}
use of com.xenoage.zong.musicxml.types.MxlScorePartwise in project Zong by Xenoage.
the class Test51b method test.
@Test
public void test() {
MxlScorePartwise score = getScore();
assertEquals(expectedMovementTitle, score.getScoreHeader().getMovementTitle());
assertEquals(expectedComposer, score.getScoreHeader().getIdentification().getCreators().get(0).getValue());
MxlScorePart part = (MxlScorePart) score.getScoreHeader().getPartList().getContent().get(0);
assertEquals(expectedPartName, part.getPartName());
}
Aggregations