Search in sources :

Example 6 with ScoreDoc

use of com.xenoage.zong.documents.ScoreDoc 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 7 with ScoreDoc

use of com.xenoage.zong.documents.ScoreDoc 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 8 with ScoreDoc

use of com.xenoage.zong.documents.ScoreDoc in project Zong by Xenoage.

the class VisualTester method start.

public static void start(VisualTest test) {
    try {
        JseZongPlatformUtils.init(test.getClass().getSimpleName());
        Log.INSTANCE.init(new DesktopLogProcessing(test.getClass().getSimpleName()));
        ScoreDoc scoreDoc = createScoreDoc(test);
        SimpleGuiDemo.start(scoreDoc);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : DesktopLogProcessing(com.xenoage.utils.jse.log.DesktopLogProcessing) IOException(java.io.IOException) ScoreDoc(com.xenoage.zong.documents.ScoreDoc)

Example 9 with ScoreDoc

use of com.xenoage.zong.documents.ScoreDoc in project Zong by Xenoage.

the class Converter method convert.

public static void convert(String... args) throws IOException {
    // exception for wrong format
    if (args.length < 4 || !args[0].equals("--convert")) {
        System.out.println("Wrong usage of parameters.");
        showHelp();
        return;
    }
    // second argument: input file
    File inputFile = new File(args[1]);
    if (!inputFile.exists()) {
        System.out.println("Input file could not be found at");
        System.out.println(inputFile.getAbsolutePath());
        return;
    }
    // third argument: output file
    File outputFile = new File(args[2]);
    // fourth argument: output format
    String formatId = args[3].toLowerCase();
    FileFormat<ScoreDoc> format = null;
    try {
        format = supportedFormats.getByID(formatId);
    } catch (IllegalArgumentException ex) {
    }
    if (format == null || format.getOutput() == null) {
        System.out.println("Can not save files in format " + formatId);
        System.out.println("Supported formats are:");
        showFormats();
        return;
    }
    // create output dir, if needed
    outputFile.getParentFile().mkdirs();
    // do the conversion
    FileInput<ScoreDoc> input = supportedFormats.getReadDefaultFormat().getInput();
    ScoreDoc doc = input.read(new JseInputStream(new FileInputStream(inputFile)), inputFile.getAbsolutePath());
    // TIDY
    doc.getLayout().updateScoreLayouts(doc.getScore());
    DocumentIO.write(doc, outputFile, format.getOutput());
}
Also used : JseInputStream(com.xenoage.utils.jse.io.JseInputStream) File(java.io.File) FileInputStream(java.io.FileInputStream) ScoreDoc(com.xenoage.zong.documents.ScoreDoc)

Example 10 with ScoreDoc

use of com.xenoage.zong.documents.ScoreDoc 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)

Aggregations

ScoreDoc (com.xenoage.zong.documents.ScoreDoc)13 MusicXmlScoreDocFileInput (com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput)6 File (java.io.File)6 Size2f (com.xenoage.utils.math.geom.Size2f)4 JseInputStream (com.xenoage.utils.jse.io.JseInputStream)3 PdfScoreDocFileOutput (com.xenoage.zong.desktop.io.pdf.out.PdfScoreDocFileOutput)3 MidiScoreDocFileOutput (com.xenoage.zong.desktop.io.midi.out.MidiScoreDocFileOutput)2 PngScoreDocFileOutput (com.xenoage.zong.desktop.io.png.out.PngScoreDocFileOutput)2 Layout (com.xenoage.zong.layout.Layout)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 List (java.util.List)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 Canvas (com.google.gwt.canvas.client.Canvas)1 Context2d (com.google.gwt.canvas.dom.client.Context2d)1 EntryPoint (com.google.gwt.core.client.EntryPoint)1 Element (com.google.gwt.dom.client.Element)1 BLOCK (com.google.gwt.dom.client.Style.Display.BLOCK)1 NONE (com.google.gwt.dom.client.Style.Display.NONE)1