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