Search in sources :

Example 1 with VoltaStartMeasure

use of com.xenoage.zong.io.midi.out.repetitions.VoltaGroup.VoltaStartMeasure in project Zong by Xenoage.

the class VoltaGroupFinder method findVoltaGroup.

/**
 * Collects all consecutive {@link Volta}s starting at the given measure
 * into a {@link VoltaGroup}.
 */
private VoltaGroup findVoltaGroup(int startMeasure) {
    CList<VoltaStartMeasure> voltasMeasures = clist();
    val scoreHeader = score.getHeader();
    for (int measure = startMeasure; measure < score.getMeasuresCount(); ) {
        Volta volta = scoreHeader.getColumnHeader(measure).getVolta();
        if (volta != null) {
            voltasMeasures.add(new VoltaStartMeasure(volta, measure));
            measure += volta.getLength();
        } else {
            break;
        }
    }
    return new VoltaGroup(voltasMeasures.close());
}
Also used : lombok.val(lombok.val) VoltaStartMeasure(com.xenoage.zong.io.midi.out.repetitions.VoltaGroup.VoltaStartMeasure) Volta(com.xenoage.zong.core.music.volta.Volta)

Example 2 with VoltaStartMeasure

use of com.xenoage.zong.io.midi.out.repetitions.VoltaGroup.VoltaStartMeasure in project Zong by Xenoage.

the class VoltaGroups method getVoltaAt.

/**
 * Gets the {@link Volta} and its start measure over the given measure.
 */
@MaybeNull
public VoltaStartMeasure getVoltaAt(int measure) {
    val group = getVoltaGroupAt(measure);
    if (group == null)
        return null;
    VoltaStartMeasure volta = null;
    for (val v : group.voltasStartMeasures) {
        volta = v;
        if (measure < v.startMeasure + v.volta.getLength())
            break;
    }
    return volta;
}
Also used : lombok.val(lombok.val) VoltaStartMeasure(com.xenoage.zong.io.midi.out.repetitions.VoltaGroup.VoltaStartMeasure) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Aggregations

VoltaStartMeasure (com.xenoage.zong.io.midi.out.repetitions.VoltaGroup.VoltaStartMeasure)2 lombok.val (lombok.val)2 MaybeNull (com.xenoage.utils.annotations.MaybeNull)1 Volta (com.xenoage.zong.core.music.volta.Volta)1