Search in sources :

Example 46 with Score

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

the class Test21b method test.

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

Example 47 with Score

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

the class Test11a method test.

@Test
public void test() {
    Score score = getScore();
    int iTime = 0;
    for (int iM = 0; iM < score.getMeasuresCount(); iM++) {
        // TODO: first time is wrong in MusicXML file - ignore
        if (iTime == 0) {
            iTime++;
            continue;
        }
        // check time
        assertEquals("element " + iTime, expectedTimes[iTime++], score.getColumnHeader(iM).getTime().getType());
    }
    assertEquals("not all times found", expectedTimes.length, iTime);
}
Also used : Score(com.xenoage.zong.core.Score) Test(org.junit.Test)

Example 48 with Score

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

the class Test11h method test.

@Test
public void test() {
    Score score = getScore();
    // time signature must be senza misura
    assertEquals(TimeType.Companion.getTimeSenzaMisura(), score.getColumnHeader(0).getTime().getType());
    // measure must contain 3 notes and have a length of 3/8
    assertEquals(3, score.getVoice(mp0).getElements().size());
    assertEquals(Companion.fr(3, 8), score.getVoice(mp0).getFilledBeats());
}
Also used : Score(com.xenoage.zong.core.Score) Test(org.junit.Test)

Example 49 with Score

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

the class Test12b method test.

@Test
public void test() {
    Score score = getScore();
    // musical context must be 4/4, C clef and no accidentals
    MusicContext context = score.getMusicContext(mp0, Interval.At, Interval.At);
    assertEquals(Companion.fr(4, 4), score.getMeasureBeats(0));
    assertEquals(ClefType.Companion.getClefTreble(), context.getClef());
    for (int i = 0; i < 7; i++) assertEquals(0, context.getKey().getAlterations()[i]);
    // there should be a C clef in the first measure
    assertEquals(ClefType.Companion.getClefTreble(), score.getMeasure(mp0).getClefs().get(Companion.get_0()).getType());
    // there should be a time signature and key signature in the measure column
    ColumnHeader header = score.getHeader().getColumnHeader(0);
    assertEquals(TimeType.Companion.getTime_4_4(), header.getTime().getType());
    assertNotNull(header.getKeys().get(Companion.get_0()));
}
Also used : Score(com.xenoage.zong.core.Score) ColumnHeader(com.xenoage.zong.core.header.ColumnHeader) MusicContext(com.xenoage.zong.core.music.MusicContext) Test(org.junit.Test)

Example 50 with Score

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

the class Test33b method test.

@Test
public void test() {
    Score score = getScore();
    Chord chord1 = (Chord) score.getVoice(atVoice(0, 0, 0)).getElement(0);
    Chord chord2 = (Chord) score.getVoice(atVoice(0, 1, 0)).getElement(0);
    assertEquals(1, chord1.getSlurs().size());
    Slur tie = chord1.getSlurs().get(0);
    assertEquals(SlurType.Tie, tie.getType());
    List<SlurWaypoint> waypoints = tie.getWaypoints();
    assertEquals(2, waypoints.size());
    assertEquals(chord1, waypoints.get(0).getChord());
    assertEquals(chord2, waypoints.get(1).getChord());
}
Also used : Slur(com.xenoage.zong.core.music.slur.Slur) Score(com.xenoage.zong.core.Score) Chord(com.xenoage.zong.core.music.chord.Chord) SlurWaypoint(com.xenoage.zong.core.music.slur.SlurWaypoint) 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