Search in sources :

Example 86 with Score

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

the class Test13a method test.

// @ToDo("Zong! supports only -7 to +7, starting in measure 9, ending in measure 38")
@Test
public void test() {
    Score score = getScore();
    TraditionalKey[] expectedKeys = getExpectedKeys();
    int iKey = 0;
    for (int i = 8; i <= 37; i++) {
        ColumnHeader column = score.getColumnHeader(i);
        TraditionalKey key = (TraditionalKey) column.getKeys().get(Companion.get_0());
        assertEquals("measure " + i, expectedKeys[iKey].getFifths(), key.getFifths());
        assertEquals("measure " + i, expectedKeys[iKey].getMode(), key.getMode());
        iKey++;
    }
}
Also used : Score(com.xenoage.zong.core.Score) ColumnHeader(com.xenoage.zong.core.header.ColumnHeader) TraditionalKey(com.xenoage.zong.core.music.key.TraditionalKey) Test(org.junit.Test)

Example 87 with Score

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

the class Test21c method test.

@Test
public void test() {
    Score score = getScore();
    MP mp = mp0;
    for (int i = 0; i < expectedChords.length; i++) {
        Chord chord = (Chord) score.getVoice(mp).getElementAt(mp.beat);
        assertEquals("chord " + i, expectedChords[i].getNotes(), chord.getNotes());
        assertEquals("chord " + i, expectedChords[i].getDuration(), chord.getDuration());
        mp = mp.withBeat(mp.beat.add(expectedChords[i].getDuration()));
        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) MP(com.xenoage.zong.core.position.MP) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 88 with Score

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

the class Test21e method test.

@Test
public void test() {
    Score score = getScore();
    // 4/4 time in first measure (implicit)
    assertEquals(Companion.fr(4, 4), score.getColumnHeader(0).getTime().getType().getMeasureBeats());
    // first measure has only a 1/4 chord and a total length of 1/4
    assertEquals(1, score.getVoice(mp0).getElements().size());
    assertEquals(Companion.fr(1, 4), score.getVoice(mp0).getElement(0).getDuration());
    assertEquals(Companion.fr(1, 4), score.getMeasure(mp0).getFilledBeats());
    // second measure has two 1/4 chords and total length of 2/4
    MP m2 = mp0.withMeasure(1);
    assertEquals(2, score.getVoice(m2).getElements().size());
    assertEquals(Companion.fr(1, 4), score.getVoice(m2).getElement(0).getDuration());
    assertEquals(Companion.fr(1, 4), score.getVoice(m2).getElement(1).getDuration());
    assertEquals(Companion.fr(2, 4), score.getMeasure(m2).getFilledBeats());
}
Also used : Score(com.xenoage.zong.core.Score) MP(com.xenoage.zong.core.position.MP) Test(org.junit.Test)

Example 89 with Score

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

the class Test21f method test.

@Test
public void test() {
    Score score = getScore();
    // 1/4 with 3 notes at beat 0
    List<VoiceElement> e = score.getVoice(mp0).getElements();
    Chord chord = (Chord) e.get(0);
    assertEquals(3, chord.getNotes().size());
    assertEquals(Companion.fr(1, 4), chord.getDuration());
    // followed by 2 rests, 1/4 and 2/4
    assertEquals(Companion.fr(1, 4), ((Rest) e.get(1)).getDuration());
    assertEquals(Companion.fr(2, 4), ((Rest) e.get(2)).getDuration());
    // segno at beat 1/4 in column (moved to the end of the measure, since we accept no mid-measure segnos)
    Direction segno = (Segno) score.getColumnHeader(0).getNavigationOrigin();
    assertNotNull(segno);
    // dynamics p at beat 1/4 in measure
    Dynamic dynamics = (Dynamic) score.getMeasure(mp0).getDirections().get(Companion.fr(1, 4));
    assertNotNull(dynamics);
    assertEquals(DynamicValue.p, dynamics.getValue());
}
Also used : Score(com.xenoage.zong.core.Score) Dynamic(com.xenoage.zong.core.music.direction.Dynamic) VoiceElement(com.xenoage.zong.core.music.VoiceElement) Segno(com.xenoage.zong.core.music.direction.Segno) Chord(com.xenoage.zong.core.music.chord.Chord) Direction(com.xenoage.zong.core.music.direction.Direction) Test(org.junit.Test)

Example 90 with Score

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

the class Test23f method test.

@Test
public void test() {
    Score score = getScore();
    checkDurations(score.getStaff(0), expectedDurations[0]);
    checkDurations(score.getStaff(1), expectedDurations[1]);
}
Also used : Score(com.xenoage.zong.core.Score) 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