Search in sources :

Example 41 with Score

use of com.xenoage.zong.core.Score in project Zong by Xenoage.

the class Test31a method test.

@ToDo("add support for multiple direction-types within a single MusicXML direction")
@Test
public void test() {
    Score score = getScore();
    // test directions
    for (Tuple2<MP, ?> item : expectedDirections) {
        MP mp = item.get1();
        List<?> directions = null;
        // in the column header instead, and not in the measure
        if (item.get2() instanceof Tempo)
            directions = score.getColumnHeader(mp.measure).getTempos().getAll(mp.beat);
        else if (item.get2() instanceof NavigationSign)
            directions = score.getColumnHeader(mp.measure).getOtherDirections().getAll(mp.beat);
        else
            directions = score.getMeasure(mp).getDirections().getAll(mp.beat);
        // check correct classes
        if (item.get2() instanceof Direction) {
            // single direction at this beat expected
            assertEquals("" + mp, 1, directions.size());
            assertEquals("" + mp, item.get2().getClass(), directions.get(0).getClass());
        } else if (item.get2() instanceof List<?>) {
        // List<?> l = (List<?>) item.get2();
        // multiple directions at this beat expected
        // TODO: add support for multiple direction-types within a single MusicXML direction
        // assertEquals(""+mp, l.size(), directions.size());
        // for (int i : range(l))
        // assertEquals(""+mp+"["+i+"]", l.get(i).getClass(), directions.get(i).getClass());
        }
    }
    // segno and coda
    assertEquals(MusicElementType.Segno, score.getColumnHeader(1).getNavigationTarget().getMusicElementType());
    assertEquals(MusicElementType.Coda, score.getColumnHeader(1).getNavigationOrigin().getMusicElementType());
}
Also used : Score(com.xenoage.zong.core.Score) MP(com.xenoage.zong.core.position.MP) Tempo(com.xenoage.zong.core.music.direction.Tempo) NavigationSign(com.xenoage.zong.core.music.direction.NavigationSign) Direction(com.xenoage.zong.core.music.direction.Direction) ToDo(musicxmltestsuite.tests.utils.ToDo) Test(org.junit.Test)

Example 42 with Score

use of com.xenoage.zong.core.Score in project Zong by Xenoage.

the class Test31c method test.

@Test
public void test() {
    Score score = getScore();
    for (Tuple2<MP, Tempo> tempo : expectedTempos) {
        MP mp = tempo.get1();
        List<Tempo> temposAtBeat = score.getColumnHeader(mp.measure).getTempos().getAll(mp.beat);
        assertEquals(1, temposAtBeat.size());
        // TODO: add equals for tempo
        assertEquals(tempo.get2().getBaseBeat(), temposAtBeat.get(0).getBaseBeat());
        assertEquals(tempo.get2().getBeatsPerMinute(), temposAtBeat.get(0).getBeatsPerMinute());
    }
}
Also used : Score(com.xenoage.zong.core.Score) MP(com.xenoage.zong.core.position.MP) Tempo(com.xenoage.zong.core.music.direction.Tempo) Test(org.junit.Test)

Example 43 with Score

use of com.xenoage.zong.core.Score in project Zong by Xenoage.

the class Test32a method test.

@Test
public void test() {
    Score score = getScore();
    for (Tuple2<MP, ?> item : expectedAnnotations) {
        MP mp = item.get1();
        List<?> annotations = null;
        Chord chord = (Chord) score.getVoice(mp).getElementAt(mp.beat);
        assertNotNull("" + mp, chord);
        // in this test, the chords contain either directions or annotations
        if (false == chord.getDirections().isEmpty())
            annotations = chord.getDirections();
        else
            annotations = chord.getAnnotations();
        // check correct classes
        if (item.get2() instanceof Direction) {
            // single direction at this beat expected
            assertEquals("" + mp, 1, annotations.size());
            assertEquals("" + mp, item.get2().getClass(), annotations.get(0).getClass());
        } else if (item.get2() instanceof List<?>) {
            // list of annotations
            // we ignore the order here (MusicXML does not contain a order)
            assertEquals("" + mp, set((List<?>) item.get2()), set(annotations));
        } else {
            // single annotation
            assertEquals("" + mp, 1, annotations.size());
            assertEquals("" + mp, item.get2(), annotations.get(0));
        }
    }
}
Also used : Score(com.xenoage.zong.core.Score) MP(com.xenoage.zong.core.position.MP) Chord(com.xenoage.zong.core.music.chord.Chord) Direction(com.xenoage.zong.core.music.direction.Direction) Test(org.junit.Test)

Example 44 with Score

use of com.xenoage.zong.core.Score in project Zong by Xenoage.

the class Test32b method testStyle.

@Test
public void testStyle() {
    Score score = getScore();
    for (int i = 0; i < expectedTexts.size(); ) {
        MP mp = expectedTexts.get(i).get1();
        List<Direction> directions = score.getMeasure(mp).getDirections().getAll(mp.beat);
        assertTrue("" + mp, directions.size() > 0);
        for (val direction : directions) {
            assertTrue("" + mp, direction instanceof Words);
            check((Words) direction, expectedTexts.get(i).get2(), mp);
            i++;
        }
    }
}
Also used : lombok.val(lombok.val) Score(com.xenoage.zong.core.Score) MP(com.xenoage.zong.core.position.MP) Words(com.xenoage.zong.core.music.direction.Words) Direction(com.xenoage.zong.core.music.direction.Direction) Test(org.junit.Test)

Example 45 with Score

use of com.xenoage.zong.core.Score in project Zong by Xenoage.

the class Test13b method test.

@Test
public void test() {
    Score score = getScore();
    TraditionalKey[] expectedKeys = getExpectedKeys();
    MP mp = mp0;
    for (int iKey : range(expectedKeys)) {
        ColumnHeader column = score.getColumnHeader(mp.measure);
        TraditionalKey key = (TraditionalKey) column.getKeys().get(mp.beat);
        assertNotNull("mp " + mp, key);
        assertEquals("mp " + mp, expectedKeys[iKey].getFifths(), key.getFifths());
        assertEquals("mp " + mp, expectedKeys[iKey].getMode(), key.getMode());
        mp = mp.withBeat(mp.beat.add(Companion.fr(1, 4)));
        if (mp.beat.compareTo(Companion.get_1()) >= 0) {
            mp = mp.withMeasure(mp.measure + 1).withBeat(Companion.get_0());
        }
    }
}
Also used : Score(com.xenoage.zong.core.Score) ColumnHeader(com.xenoage.zong.core.header.ColumnHeader) MP(com.xenoage.zong.core.position.MP) TraditionalKey(com.xenoage.zong.core.music.key.TraditionalKey) Test(org.junit.Test)

Aggregations

Score (com.xenoage.zong.core.Score)99 Test (org.junit.Test)62 Rest (com.xenoage.zong.core.music.rest.Rest)22 MP (com.xenoage.zong.core.position.MP)19 Voice (com.xenoage.zong.core.music.Voice)15 Cursor (com.xenoage.zong.io.selection.Cursor)15 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)14 Chord (com.xenoage.zong.core.music.chord.Chord)11 StavesList (com.xenoage.zong.core.music.StavesList)9 MusicXmlScoreFileInputTest (com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInputTest)9 Part (com.xenoage.zong.core.music.Part)8 ColumnHeader (com.xenoage.zong.core.header.ColumnHeader)7 lombok.val (lombok.val)7 TraditionalKey (com.xenoage.zong.core.music.key.TraditionalKey)6 Direction (com.xenoage.zong.core.music.direction.Direction)5 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)5 Size2f (com.xenoage.utils.math.geom.Size2f)4 PartAdd (com.xenoage.zong.commands.core.music.PartAdd)4 ScoreFormat (com.xenoage.zong.core.format.ScoreFormat)4 ScoreHeader (com.xenoage.zong.core.header.ScoreHeader)4