Search in sources :

Example 1 with MusicXmlScoreFileInput

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

the class ScoreLayouterTest method testSampleFiles.

/**
 * Try to layout all official MusicXML 1.1 and 2.0 sample files.
 * We can not test for the correct layout of course, but at least
 * we want to have no exceptions.
 */
@Test
public void testSampleFiles() throws Exception {
    SymbolPool symbolPool = sync(new SymbolPoolReader("default"));
    LayoutSettings layoutSettings = LayoutSettingsReader.read(jsePlatformUtils().openFile("data/test/layout/LayoutSettingsTest.xml"));
    for (String file : MusicXmlScoreFileInputTest.getSampleFiles()) {
        try {
            // System.out.println(file);
            Score score = new MusicXmlScoreFileInput().read(jsePlatformUtils().openFile(file), file);
            Size2f areaSize = new Size2f(150, 10000);
            Context context = new Context(score, symbolPool, layoutSettings);
            Target target = Target.completeLayoutTarget(new ScoreLayoutArea(areaSize));
            ScoreLayouter layouter = new ScoreLayouter(context, target);
            layouter.createLayoutWithExceptions();
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("Failed to layout file: " + file);
        }
    }
}
Also used : SymbolPoolReader(com.xenoage.zong.io.symbols.SymbolPoolReader) Score(com.xenoage.zong.core.Score) LayoutSettings(com.xenoage.zong.musiclayout.settings.LayoutSettings) Size2f(com.xenoage.utils.math.geom.Size2f) SymbolPool(com.xenoage.zong.symbols.SymbolPool) MusicXmlScoreFileInput(com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInput) MusicXmlScoreFileInputTest(com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInputTest) Test(org.junit.Test)

Example 2 with MusicXmlScoreFileInput

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

the class MidiConverterTest method testSampleFiles.

@Test
public void testSampleFiles() {
    boolean writeFiles = true;
    for (String file : MusicXmlScoreFileInputTest.getSampleFiles()) {
        try {
            val score = new MusicXmlScoreFileInput().read(jsePlatformUtils().openFile(file), file);
            val sequence = MidiConverter.convertToSequence(score, optionsForPlayback, new JseMidiSequenceWriter());
            if (writeFiles) {
                // try: write to file
                new File("temp").mkdirs();
                System.out.println("Converting: " + file);
                MidiSystem.write(sequence.getSequence(), 1, new File("temp/" + file.replaceAll("/", "_") + ".mid"));
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            fail("Failed to load file: " + file);
        }
    }
}
Also used : lombok.val(lombok.val) JseMidiSequenceWriter(com.xenoage.zong.desktop.io.midi.out.JseMidiSequenceWriter) MusicXmlScoreFileInput(com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInput) File(java.io.File) MusicXmlScoreFileInputTest(com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInputTest) Test(org.junit.Test)

Example 3 with MusicXmlScoreFileInput

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

the class MusicXmlInTest method getScoreOrException.

default Score getScoreOrException() throws Exception {
    Base base = (Base) this;
    String filepath = Base.dirPath + base.getFileName();
    return new MusicXmlScoreFileInput().read(jsePlatformUtils().openFile(filepath), filepath);
}
Also used : MusicXmlScoreFileInput(com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInput) Base(musicxmltestsuite.tests.base.Base)

Aggregations

MusicXmlScoreFileInput (com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInput)3 MusicXmlScoreFileInputTest (com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInputTest)2 Test (org.junit.Test)2 Size2f (com.xenoage.utils.math.geom.Size2f)1 Score (com.xenoage.zong.core.Score)1 JseMidiSequenceWriter (com.xenoage.zong.desktop.io.midi.out.JseMidiSequenceWriter)1 SymbolPoolReader (com.xenoage.zong.io.symbols.SymbolPoolReader)1 LayoutSettings (com.xenoage.zong.musiclayout.settings.LayoutSettings)1 SymbolPool (com.xenoage.zong.symbols.SymbolPool)1 File (java.io.File)1 lombok.val (lombok.val)1 Base (musicxmltestsuite.tests.base.Base)1