Search in sources :

Example 1 with Score

use of com.xenoage.zong.io.musicxml.opus.Score in project Zong by Xenoage.

the class CompressedFileInput method loadScore.

/**
 * Loads and returns the {@link com.xenoage.zong.core.Score} at the given path.
 */
public com.xenoage.zong.core.Score loadScore(String path) throws InvalidFormatException, IOException {
    BufferedInputStream bis = new BufferedInputStream(zip.openFile(path));
    // XML or compressed?
    bis.mark();
    FileType fileType = FileTypeReader.getFileType(bis);
    bis.reset();
    bis.unmark();
    if (fileType == null)
        throw new InvalidFormatException("Score has invalid format: " + path);
    com.xenoage.zong.core.Score ret = null;
    switch(fileType) {
        case Compressed:
            ret = loadCompressedScore(path);
            break;
        case XMLScorePartwise:
            ret = new MusicXmlScoreFileInput().read(bis, path);
            break;
        case XMLScoreTimewise:
            throw new IllegalStateException("score-timewise is currently not implemented");
        default:
            throw new InvalidFormatException("Score has invalid format: " + path);
    }
    bis.close();
    return ret;
}
Also used : Score(com.xenoage.zong.io.musicxml.opus.Score) BufferedInputStream(com.xenoage.utils.io.BufferedInputStream) FileType(com.xenoage.zong.io.musicxml.FileType) InvalidFormatException(com.xenoage.utils.exceptions.InvalidFormatException)

Example 2 with Score

use of com.xenoage.zong.io.musicxml.opus.Score in project Zong by Xenoage.

the class OpusFileInput method readScore.

private Score readScore(XmlReader reader) {
    String href = reader.getAttribute("href");
    Boolean newPage = Parser.parseBooleanNullYesNo(reader.getAttribute("new-page"));
    return new Score(new LinkAttributes(href), newPage);
}
Also used : LinkAttributes(com.xenoage.zong.io.musicxml.link.LinkAttributes) Score(com.xenoage.zong.io.musicxml.opus.Score)

Aggregations

Score (com.xenoage.zong.io.musicxml.opus.Score)2 InvalidFormatException (com.xenoage.utils.exceptions.InvalidFormatException)1 BufferedInputStream (com.xenoage.utils.io.BufferedInputStream)1 FileType (com.xenoage.zong.io.musicxml.FileType)1 LinkAttributes (com.xenoage.zong.io.musicxml.link.LinkAttributes)1