use of com.xenoage.zong.core.music.Measure in project Zong by Xenoage.
the class VoicesBeatOffsetterTest method createVoiceSpacings.
/**
* Create {@link VoiceSpacing}s for the first measure column
* of the given {@link Score}.
*/
private LinkedList<VoiceSpacing> createVoiceSpacings(Score score) {
LinkedList<VoiceSpacing> ret = new LinkedList<>();
for (int iStaff : range(0, score.getStavesCount() - 1)) {
Measure measure = score.getMeasure(atMeasure(iStaff, 0));
for (Voice voice : measure.getVoices()) {
Fraction beat = Companion.fr(0);
ArrayList<ElementSpacing> se = alist();
float offset = 0;
for (VoiceElement e : voice.getElements()) {
// compute width
float width = 0;
if (e.getDuration().equals(Companion.get_0()))
width = width_grace;
else if (e.getDuration().equals(dur_1_8))
width = width_1_8;
else if (e.getDuration().equals(dur_1_6))
width = width_1_6;
else if (e.getDuration().equals(dur_1_4))
width = width_1_4;
else if (e.getDuration().equals(dur_3_8))
width = width_3_8;
else if (e.getDuration().equals(dur_1_2))
width = width_1_2;
else if (e.getDuration().equals(dur_1_1))
width = width_1_1;
// create spacing element with offset
se.add(new ChordSpacing(new ChordNotation((Chord) e), beat, offset));
beat = beat.add(e.getDuration());
offset += width;
}
se.add(new BorderSpacing(beat, offset));
ret.add(new VoiceSpacing(voice, score.getFormat().getInterlineSpace(), se));
}
}
return ret;
}
use of com.xenoage.zong.core.music.Measure 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);
}
}
}
Aggregations