use of com.xenoage.zong.core.music.direction.Segno in project Zong by Xenoage.
the class RepetitionsFinder method collectJumps.
/**
* Creates the list of jumps for this score.
*/
private void collectJumps() {
// if not null, the next segno will jump back to this one
Segno lastSegno = null;
// in the next volta group, jump to this repeat number
int lastVoltaCounter = 1;
Fraction measureStartBeat = null;
nextMeasure: for (currentMeasureIndex = 0; currentMeasureIndex < score.getMeasuresCount(); ) {
val measure = score.getColumnHeader(currentMeasureIndex);
// are we stuck within an endless loop? then do not jump at all.
if (jumps.size() > maxJumps) {
jumps.clear();
return;
}
// enter a volta
if (voltaGroups.getVoltaGroupStartingAt(currentMeasureIndex) != null)
if (processVolta())
continue nextMeasure;
// inner backward repeat barlines
if (isWithRepeats) {
for (val e : getInnerBarlines()) {
val innerBarline = e.getElement();
val eTime = Companion.time(currentMeasureIndex, e.getBeat());
if (innerBarline.getRepeat().isBackward())
if (processBackwardRepeat(innerBarline, eTime))
continue nextMeasure;
}
}
// backward repeat at measure end
val endBarline = measure.getEndBarline();
val endTime = Companion.time(currentMeasureIndex + 1, Companion.get_0());
if (isWithRepeats && endBarline != null) {
if (endBarline.getRepeat().isBackward()) {
// ignore it at the end of the final volta of a volta group, otherwise we are stuck in an endless loop
if (false == isFinalVoltaAt(currentMeasureIndex))
if (processBackwardRepeat(endBarline, endTime))
continue nextMeasure;
}
}
// origin navigation sign
// we read them after the backward repeat barlines. e.g. when there is both
// a repeat and a "to coda", we first play the repeat and then the "to coda".
val sign = measure.getNavigationOrigin();
if (sign != null) {
// da capo ,
if (MusicElementType.DaCapo.is(sign))
if (processDaCapo((DaCapo) sign))
continue nextMeasure;
// target segno
if (MusicElementType.Segno.is(sign))
if (processSegno((Segno) sign))
continue nextMeasure;
// to coda
if (MusicElementType.Coda.is(sign))
if (processCoda((Coda) sign))
continue nextMeasure;
}
// no jump found in this measure, continue
currentMeasureIndex++;
currentMeasureStartBeat = null;
}
}
use of com.xenoage.zong.core.music.direction.Segno in project Zong by Xenoage.
the class Test21f method test.
@Test
public void test() {
Score score = getScore();
// 1/4 with 3 notes at beat 0
List<VoiceElement> e = score.getVoice(mp0).getElements();
Chord chord = (Chord) e.get(0);
assertEquals(3, chord.getNotes().size());
assertEquals(Companion.fr(1, 4), chord.getDuration());
// followed by 2 rests, 1/4 and 2/4
assertEquals(Companion.fr(1, 4), ((Rest) e.get(1)).getDuration());
assertEquals(Companion.fr(2, 4), ((Rest) e.get(2)).getDuration());
// segno at beat 1/4 in column (moved to the end of the measure, since we accept no mid-measure segnos)
Direction segno = (Segno) score.getColumnHeader(0).getNavigationOrigin();
assertNotNull(segno);
// dynamics p at beat 1/4 in measure
Dynamic dynamics = (Dynamic) score.getMeasure(mp0).getDirections().get(Companion.fr(1, 4));
assertNotNull(dynamics);
assertEquals(DynamicValue.p, dynamics.getValue());
}
Aggregations