Search in sources :

Example 16 with VoiceElement

use of com.xenoage.zong.core.music.VoiceElement 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)

Example 17 with VoiceElement

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

the class VoiceTest method assertEqualsVoice.

/**
 * Tests the equality of the given voices, but only the durations of the rests
 * and the durations and notes of the chords.
 */
public static void assertEqualsVoice(Voice expectedVoice, Voice voice, MP voiceMP) {
    assertEquals("" + voiceMP, expectedVoice.getElements().size(), voice.getElements().size());
    for (int i : range(expectedVoice.getElements())) {
        VoiceElement expElement = expectedVoice.getElement(i);
        VoiceElement element = voice.getElement(i);
        assertEquals(expElement.getClass(), element.getClass());
        assertEquals(expElement.getDuration(), element.getDuration());
        if (expElement instanceof Chord)
            assertEqualsChord((Chord) expElement, (Chord) element, voiceMP.withElement(i));
    }
}
Also used : VoiceElement(com.xenoage.zong.core.music.VoiceElement) Chord(com.xenoage.zong.core.music.chord.Chord) ChordTest.assertEqualsChord(musicxmltestsuite.tests.utils.ChordTest.assertEqualsChord)

Aggregations

VoiceElement (com.xenoage.zong.core.music.VoiceElement)17 Voice (com.xenoage.zong.core.music.Voice)12 Test (org.junit.Test)11 Chord (com.xenoage.zong.core.music.chord.Chord)8 ElementSpacing (com.xenoage.zong.musiclayout.spacing.ElementSpacing)6 VoiceSpacing (com.xenoage.zong.musiclayout.spacing.VoiceSpacing)6 ChordNotation (com.xenoage.zong.musiclayout.notation.ChordNotation)5 RestNotation (com.xenoage.zong.musiclayout.notation.RestNotation)5 ElementWidth (com.xenoage.zong.musiclayout.spacing.ElementWidth)5 Measure (com.xenoage.zong.core.music.Measure)4 Staff (com.xenoage.zong.core.music.Staff)4 VoiceTest (com.xenoage.zong.core.music.VoiceTest)4 Notations (com.xenoage.zong.musiclayout.notation.Notations)4 LayoutSettingsTest (com.xenoage.zong.musiclayout.settings.LayoutSettingsTest)4 Fraction (com.xenoage.utils.math.Fraction)3 Pitch (com.xenoage.zong.core.music.Pitch)2 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)2 ToDo (musicxmltestsuite.tests.utils.ToDo)2 Score (com.xenoage.zong.core.Score)1 MusicElement (com.xenoage.zong.core.music.MusicElement)1