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);
}
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));
}
}
Aggregations