Search in sources :

Example 1 with Volta

use of com.xenoage.zong.core.music.volta.Volta in project Zong by Xenoage.

the class Context method closeVolta.

public ClosedVolta closeVolta(boolean rightHook) {
    OpenVolta openVolta = openElements.getOpenVolta();
    if (openVolta == null) {
        reportError("No volta open");
        return null;
    }
    int length = mp.getMeasure() - openVolta.startMeasure + 1;
    if (length < 1) {
        reportError("Invalid volta");
        return null;
    }
    Volta volta = new Volta(length, openVolta.numbers, openVolta.caption, rightHook);
    openElements.setOpenVolta(null);
    return new ClosedVolta(volta, openVolta.startMeasure);
}
Also used : SlurWaypoint(com.xenoage.zong.core.music.slur.SlurWaypoint) Volta(com.xenoage.zong.core.music.volta.Volta)

Example 2 with Volta

use of com.xenoage.zong.core.music.volta.Volta in project Zong by Xenoage.

the class TimeMapperTest method getScore.

/**
 * Creates the following score (each space is a quarter note)
 *
 * measures:
 * repetitions: voltas/signs:            1───┐2───┐   d.c. senza rep
 *              barlines:     |    |:   |   :|    |1   ||
 * part 0: staff 0: voice 0:  |1   |1   |2 2 |1   |1   ||
 *                  voice 1:  |    |442 |42 4|1 d |1   ||   //d = direction
 *         staff 1: voice 0:  |2 44|1   |    |1   |1   ||
 * part 1: staff 2: voice 0:  |1   |1   |2 2 |    |2 2 ||
 *
 * play ranges:               0---------------
 *                                 1----     2---------
 *                            3---------     4---------
 */
private Score getScore() {
    val score = new Score();
    new PartAdd(score, new Part("p0", null, 2, null), 0, null).execute();
    new PartAdd(score, new Part("p1", null, 1, null), 1, null).execute();
    new MeasureAdd(score, 5).execute();
    // time, barlines, voltas and signs
    score.getColumnHeader(0).setTime(new TimeSignature(TimeType.Companion.getTime_4_4()));
    score.getColumnHeader(1).setStartBarline(Companion.barlineForwardRepeat(Regular));
    score.getColumnHeader(2).setVolta(new Volta(1, range(1, 1), "1", true));
    score.getColumnHeader(2).setEndBarline(Companion.barlineBackwardRepeat(Regular, 1));
    score.getColumnHeader(3).setVolta(new Volta(1, range(2, 2), "2", true));
    score.getColumnHeader(4).setNavigationOrigin(new DaCapo(false));
    // staff 0, voice 0
    val cursor = new Cursor(score, mp0, true);
    cursor.write(e(1));
    cursor.write(e(1));
    cursor.write(e(2));
    cursor.write(e(2));
    cursor.write(e(1));
    cursor.write(e(1));
    // staff 0, voice 1
    cursor.setMp(atElement(0, 1, 1, 0));
    cursor.write(e(4));
    cursor.write(e(4));
    cursor.write(e(2));
    cursor.write(e(4));
    cursor.write(e(2));
    cursor.write(e(4));
    cursor.write(e(1));
    cursor.write(e(1));
    new MeasureElementWrite(new Dynamic(DynamicValue.f), score.getMeasure(atMeasure(0, 3)), Companion.get_1$2()).execute();
    // staff 1, voice 0
    cursor.setMp(atElement(1, 0, 0, 0));
    cursor.write(e(2));
    cursor.write(e(4));
    cursor.write(e(4));
    cursor.write(e(1));
    cursor.setMp(atElement(1, 2, 0, 0));
    cursor.write(e(1));
    cursor.write(e(1));
    // staff 2, voice 0
    cursor.setMp(atElement(2, 0, 0, 0));
    cursor.write(e(1));
    cursor.write(e(1));
    cursor.write(e(2));
    cursor.write(e(2));
    cursor.setMp(atElement(2, 4, 0, 0));
    cursor.write(e(2));
    cursor.write(e(2));
    return score;
}
Also used : lombok.val(lombok.val) Score(com.xenoage.zong.core.Score) MeasureAdd(com.xenoage.zong.commands.core.music.MeasureAdd) Dynamic(com.xenoage.zong.core.music.direction.Dynamic) Part(com.xenoage.zong.core.music.Part) PartAdd(com.xenoage.zong.commands.core.music.PartAdd) DaCapo(com.xenoage.zong.core.music.direction.DaCapo) Cursor(com.xenoage.zong.io.selection.Cursor) MeasureElementWrite(com.xenoage.zong.commands.core.music.MeasureElementWrite) TimeSignature(com.xenoage.zong.core.music.time.TimeSignature) Volta(com.xenoage.zong.core.music.volta.Volta)

Example 3 with Volta

use of com.xenoage.zong.core.music.volta.Volta 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 4 with Volta

use of com.xenoage.zong.core.music.volta.Volta in project Zong by Xenoage.

the class VoltaGroupFinderTest method createScore.

private Score createScore() {
    Score score = ScoreFactory.create1Staff();
    new MeasureAdd(score, getLast(getLast(voltaGroups)) + 4).execute();
    for (val voltaGroup : voltaGroups) {
        for (int iVolta = 0; iVolta < voltaGroup.length - 1; iVolta++) {
            int startMeasure = voltaGroup[iVolta];
            int length = voltaGroup[iVolta + 1] - voltaGroup[iVolta];
            val numbers = range(iVolta + 1, iVolta + 1);
            score.getHeader().getColumnHeader(startMeasure).setVolta(new Volta(length, numbers, numbers.toString(), false));
        }
    }
    return score;
}
Also used : lombok.val(lombok.val) Score(com.xenoage.zong.core.Score) MeasureAdd(com.xenoage.zong.commands.core.music.MeasureAdd) Volta(com.xenoage.zong.core.music.volta.Volta)

Aggregations

Volta (com.xenoage.zong.core.music.volta.Volta)4 lombok.val (lombok.val)3 MeasureAdd (com.xenoage.zong.commands.core.music.MeasureAdd)2 Score (com.xenoage.zong.core.Score)2 MeasureElementWrite (com.xenoage.zong.commands.core.music.MeasureElementWrite)1 PartAdd (com.xenoage.zong.commands.core.music.PartAdd)1 Part (com.xenoage.zong.core.music.Part)1 DaCapo (com.xenoage.zong.core.music.direction.DaCapo)1 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)1 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)1 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)1 VoltaStartMeasure (com.xenoage.zong.io.midi.out.repetitions.VoltaGroup.VoltaStartMeasure)1 Cursor (com.xenoage.zong.io.selection.Cursor)1