Search in sources :

Example 1 with MusicXmlScoreDocFileInput

use of com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput in project Zong by Xenoage.

the class VisualHtmlReport method renderScore.

/**
 * Renders the given score into an image file.
 */
private void renderScore(File scoreFile) throws IOException {
    ScoreDoc doc = DocumentIO.read(scoreFile, new MusicXmlScoreDocFileInput());
    File pngFile = new File(new File(dirReport, appDir), scoreFile.getName() + ".png");
    DocumentIO.write(doc, pngFile, new PngScoreDocFileOutput());
    cropScoreImage(pngFile);
}
Also used : PngScoreDocFileOutput(com.xenoage.zong.desktop.io.png.out.PngScoreDocFileOutput) MusicXmlScoreDocFileInput(com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput) File(java.io.File) ScoreDoc(com.xenoage.zong.documents.ScoreDoc)

Example 2 with MusicXmlScoreDocFileInput

use of com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput in project Zong by Xenoage.

the class MusicXmlMassTest method testFile.

// */
private boolean testFile(File file) {
    try {
        // Load the file
        // TIDY
        ScoreDocFactory.setErrorLayoutEnabled(false);
        ScoreDoc score = new MusicXmlScoreDocFileInput().read(new JseInputStream(file), file.getAbsolutePath());
        // TIDY
        ScoreDocFactory.setErrorLayoutEnabled(true);
        // Check layout of loaded file
        if (checkLayout) {
            checkLayout(score, file.getName());
        }
        // Save it as MusicXML
        File mxlSavedFile = getTempOutputPath(file, "-saved.mxl");
        if (saveAsMxl) {
        // new MusicXMLScoreDocFileOutput().write(score, new FileOutputStream(mxlSavedFile), mxlSavedFile);
        }
        // Save it as PDF
        if (saveAsPdf) {
            File pdfFile = getTempOutputPath(file, ".pdf");
            new PdfScoreDocFileOutput().write(score, 0, new JseOutputStream(pdfFile));
        }
        // Save it as MIDI
        if (saveAsMid) {
            File midFile = getTempOutputPath(file, ".mid");
            new MidiScoreDocFileOutput().write(score, 0, new JseOutputStream(midFile));
        }
        // Load it from saved MusicXML
        if (loadFromSavedMxl) {
        // TODO
        }
        // Success
        System.out.print("OK:   " + file.toString().substring(dir.length()) + " (" + score.getScore().getInfo().getTitle() + ")");
        @SuppressWarnings("unchecked") List<String> errorMessages = (List<String>) score.getScore().getMetaData().get("mxlerrors");
        if (errorMessages != null)
            System.out.print("  ! " + errorMessages.size() + " warning(s)");
        System.out.println();
        return true;
    } catch (Throwable ex) {
        ex.printStackTrace();
        // fail("Failed to load file: " + file);
        System.out.println("fail: " + file.toString().substring(dir.length()));
        return false;
    }
}
Also used : MusicXmlScoreDocFileInput(com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput) JseInputStream(com.xenoage.utils.jse.io.JseInputStream) JseOutputStream(com.xenoage.utils.jse.io.JseOutputStream) PdfScoreDocFileOutput(com.xenoage.zong.desktop.io.pdf.out.PdfScoreDocFileOutput) List(java.util.List) MidiScoreDocFileOutput(com.xenoage.zong.desktop.io.midi.out.MidiScoreDocFileOutput) File(java.io.File) ScoreDoc(com.xenoage.zong.documents.ScoreDoc)

Example 3 with MusicXmlScoreDocFileInput

use of com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput in project Zong by Xenoage.

the class LayoutTest method getScoreFrameLayoutOrException.

default ScoreFrameLayout getScoreFrameLayoutOrException() throws Exception {
    Base base = (Base) this;
    String filepath = Base.dirPath + base.getFileName();
    ScoreDoc doc = new MusicXmlScoreDocFileInput().read(jsePlatformUtils().openFile(filepath), filepath);
    ScoreLayout layout = new ScoreLayouter(doc, targetA4()).createScoreLayout();
    return layout.getScoreFrameLayout(0);
}
Also used : MusicXmlScoreDocFileInput(com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput) ScoreLayouter(com.xenoage.zong.musiclayout.layouter.ScoreLayouter) ScoreLayout(com.xenoage.zong.musiclayout.ScoreLayout) Base(musicxmltestsuite.tests.base.Base) ScoreDoc(com.xenoage.zong.documents.ScoreDoc)

Example 4 with MusicXmlScoreDocFileInput

use of com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput in project Zong by Xenoage.

the class MinimalDemo method main.

public static void main(String... args) throws Exception {
    // initialize platform-dependent utilities, including I/O.
    // the app name is required for the working directory
    JseZongPlatformUtils.init(appName);
    for (int i = 0; i < 1000; i++) {
        // load MusicXML file
        File inFile = new File("scores/BeetAnGeSample.xml");
        ScoreDoc doc = DocumentIO.read(inFile, new MusicXmlScoreDocFileInput());
        // convert to PDF
        File outFile = new File("demo.pdf");
        DocumentIO.write(doc, outFile, new PdfScoreDocFileOutput());
        // finished. open the PDF file.
        // Desktop.getDesktop().open(outFile);
        System.out.println(i);
    }
}
Also used : MusicXmlScoreDocFileInput(com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput) PdfScoreDocFileOutput(com.xenoage.zong.desktop.io.pdf.out.PdfScoreDocFileOutput) File(java.io.File) ScoreDoc(com.xenoage.zong.documents.ScoreDoc)

Example 5 with MusicXmlScoreDocFileInput

use of com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput in project Zong by Xenoage.

the class Content method loadScore.

/**
 * Loads the MusicXML score from the given file path.
 */
public void loadScore(String filePath) {
    try {
        ScoreDoc scoreDoc = DocumentIO.read(new File(filePath), new MusicXmlScoreDocFileInput());
        loadScore(scoreDoc);
    } catch (Exception ex) {
        Err.handle(Report.Companion.error(ex));
    }
}
Also used : MusicXmlScoreDocFileInput(com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput) File(java.io.File) ScoreDoc(com.xenoage.zong.documents.ScoreDoc)

Aggregations

MusicXmlScoreDocFileInput (com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput)6 ScoreDoc (com.xenoage.zong.documents.ScoreDoc)6 File (java.io.File)4 JseInputStream (com.xenoage.utils.jse.io.JseInputStream)2 PdfScoreDocFileOutput (com.xenoage.zong.desktop.io.pdf.out.PdfScoreDocFileOutput)2 JseOutputStream (com.xenoage.utils.jse.io.JseOutputStream)1 Size2f (com.xenoage.utils.math.geom.Size2f)1 MidiScoreDocFileOutput (com.xenoage.zong.desktop.io.midi.out.MidiScoreDocFileOutput)1 PngScoreDocFileOutput (com.xenoage.zong.desktop.io.png.out.PngScoreDocFileOutput)1 Layout (com.xenoage.zong.layout.Layout)1 ScoreLayout (com.xenoage.zong.musiclayout.ScoreLayout)1 ScoreLayouter (com.xenoage.zong.musiclayout.layouter.ScoreLayouter)1 Doc (com.xenoage.zong.webserver.model.Doc)1 Page (com.xenoage.zong.webserver.model.Page)1 ScaledPage (com.xenoage.zong.webserver.model.ScaledPage)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1