Search in sources :

Example 36 with Voice

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

the class VoiceElementWriteTest method testGraceInsert3.

/**
 * Writes elements in a voice that contains grace notes.
 * <pre>
 *         xxxx___xxxx_xx
 * into  ..aaaa...bbbb.cccc..
 *  =>   ..xxxx___xxxx_xx__..</pre>
 */
@Test
public void testGraceInsert3() {
    Score score = createTestScoreGraces();
    // in voice 0, write a 5/8 rest at position 2
    MP mp = atElement(0, 0, 0, 2);
    Voice voice = score.getVoice(mp);
    Rest r = new Rest(Companion.fr(5, 8));
    VoiceElementWrite cmd = new VoiceElementWrite(voice, mp, r, null);
    cmd.execute();
    // check notes
    assertEquals(5, voice.getElements().size());
    // here 1st grace note has step 0, 2nd 1, ...
    assertEquals(0, getStep(voice, 0));
    assertEquals(1, getStep(voice, 1));
    assertEquals(r, voice.getElement(2));
    assertEquals(6, getStep(voice, 3));
    assertEquals(0, getStep(voice, 4));
    // test undo
    cmd.undo();
    assertTestScoreGracesOriginalState(score);
}
Also used : Score(com.xenoage.zong.core.Score) Rest(com.xenoage.zong.core.music.rest.Rest) MP(com.xenoage.zong.core.position.MP) Voice(com.xenoage.zong.core.music.Voice) Test(org.junit.Test)

Example 37 with Voice

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

the class Test42b method testVoiceElements.

private void testVoiceElements() {
    for (int iStaff : range(2)) {
        for (int iMeasure : range(2)) {
            MP mpVoice = atVoice(iStaff, iMeasure, 0);
            Voice expectedVoice = expectedStaves[iStaff].getVoice(mpVoice);
            Voice voice = score.getVoice(mpVoice);
            assertEqualsVoice(expectedVoice, voice, mpVoice);
        }
    }
}
Also used : MP(com.xenoage.zong.core.position.MP) MP.atVoice(com.xenoage.zong.core.position.MP.atVoice) VoiceTest.assertEqualsVoice(musicxmltestsuite.tests.utils.VoiceTest.assertEqualsVoice) Voice(com.xenoage.zong.core.music.Voice)

Example 38 with Voice

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

the class Test46e method testVoiceElements.

private void testVoiceElements() {
    for (int iMeasure : range(2)) {
        Measure expectedMeasure = expectedStaff.getMeasure(iMeasure);
        Measure measure = score.getMeasure(atMeasure(0, iMeasure));
        int expectedVoicesCount = expectedMeasure.getVoices().size();
        assertEquals(expectedVoicesCount, measure.getVoices().size());
        for (int iVoice : range(expectedVoicesCount)) {
            MP mpVoice = atVoice(0, iMeasure, iVoice);
            Voice expectedVoice = expectedStaff.getVoice(mpVoice);
            Voice voice = score.getVoice(mpVoice);
            assertEqualsVoice(expectedVoice, voice, mpVoice);
        }
    }
}
Also used : MP(com.xenoage.zong.core.position.MP) MP.atMeasure(com.xenoage.zong.core.position.MP.atMeasure) Measure(com.xenoage.zong.core.music.Measure) MP.atVoice(com.xenoage.zong.core.position.MP.atVoice) VoiceTest.assertEqualsVoice(musicxmltestsuite.tests.utils.VoiceTest.assertEqualsVoice) Voice(com.xenoage.zong.core.music.Voice)

Example 39 with Voice

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

the class Utils method checkDurations.

public static void checkDurations(Staff staff, Fraction... expectedDurations) {
    int iDuration = 0;
    for (int iM = 0; iM < staff.getMeasures().size(); iM++) {
        Voice voice = staff.getMeasure(iM).getVoice(0);
        for (VoiceElement e : voice.getElements()) {
            // check duration
            assertEquals("element " + iDuration, expectedDurations[iDuration++], e.getDuration());
        }
    }
    assertEquals("not all element found", expectedDurations.length, iDuration);
}
Also used : VoiceElement(com.xenoage.zong.core.music.VoiceElement) Voice(com.xenoage.zong.core.music.Voice) SlurWaypoint(com.xenoage.zong.core.music.slur.SlurWaypoint)

Aggregations

Voice (com.xenoage.zong.core.music.Voice)39 Test (org.junit.Test)25 Rest (com.xenoage.zong.core.music.rest.Rest)16 Score (com.xenoage.zong.core.Score)15 MP (com.xenoage.zong.core.position.MP)14 VoiceElement (com.xenoage.zong.core.music.VoiceElement)12 Chord (com.xenoage.zong.core.music.chord.Chord)10 Measure (com.xenoage.zong.core.music.Measure)8 VoiceSpacing (com.xenoage.zong.musiclayout.spacing.VoiceSpacing)7 Staff (com.xenoage.zong.core.music.Staff)6 ChordNotation (com.xenoage.zong.musiclayout.notation.ChordNotation)6 ElementSpacing (com.xenoage.zong.musiclayout.spacing.ElementSpacing)5 Fraction (com.xenoage.utils.math.Fraction)4 VoiceTest (com.xenoage.zong.core.music.VoiceTest)4 Notations (com.xenoage.zong.musiclayout.notation.Notations)4 RestNotation (com.xenoage.zong.musiclayout.notation.RestNotation)4 LayoutSettingsTest (com.xenoage.zong.musiclayout.settings.LayoutSettingsTest)4 ElementWidth (com.xenoage.zong.musiclayout.spacing.ElementWidth)4 MP.atVoice (com.xenoage.zong.core.position.MP.atVoice)3 BeatOffset (com.xenoage.zong.musiclayout.spacing.BeatOffset)3