Search in sources :

Example 1 with WedgeEnd

use of com.xenoage.zong.core.music.direction.WedgeEnd in project Zong by Xenoage.

the class DynamicsFinder method getWedgeEndAt.

/**
 * Checks, if there is a {@link WedgeEnd} at the given time within the given staff (not a voice).
 * If yes, the given open wedge is closed and returned.
 */
@MaybeNull
private GradientDynamics getWedgeEndAt(int staff, Time time, GradientDynamics openWedge) {
    val measure = score.getMeasure(atMeasure(staff, time.getMeasure()));
    val foundDynamic = (Dynamic) measure.getDirections().get(time.getBeat(), MusicElementType.Dynamic);
    val foundWedgeEnd = (WedgeEnd) measure.getDirections().get(time.getBeat(), MusicElementType.WedgeEnd);
    if (foundWedgeEnd != null) {
        val endDynamicValue = (foundDynamic != null ? foundDynamic.getValue() : openWedge.end);
        return new GradientDynamics(openWedge.start, endDynamicValue);
    }
    return null;
}
Also used : lombok.val(lombok.val) Dynamic(com.xenoage.zong.core.music.direction.Dynamic) WedgeEnd(com.xenoage.zong.core.music.direction.WedgeEnd) GradientDynamics(com.xenoage.zong.io.midi.out.dynamics.type.GradientDynamics) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Example 2 with WedgeEnd

use of com.xenoage.zong.core.music.direction.WedgeEnd in project Zong by Xenoage.

the class DynamicsFinderTest method getAdvancedScore.

/**
 * See {@link #testAdvanced()}.
 */
private Score getAdvancedScore() {
    Score score = new Score();
    Wedge w;
    new PartAdd(score, new Part("", null, 2, null), 0, null).execute();
    new MeasureAdd(score, 5).execute();
    // time signature and repeats
    new ColumnElementWrite(new TimeSignature(TimeType.Companion.getTime_4_4()), score.getColumnHeader(0), null, null).execute();
    new ColumnElementWrite(Companion.barlineForwardRepeat(Regular), score.getColumnHeader(1), null, MeasureSide.Left).execute();
    new ColumnElementWrite(Companion.barlineBackwardRepeat(Regular, 1), score.getColumnHeader(2), null, MeasureSide.Right).execute();
    // staff 0
    new MeasureElementWrite(new Dynamic(mp), score.getMeasure(atMeasure(0, 0)), Companion.get_0()).execute();
    new MeasureElementWrite(new Dynamic(pp), score.getMeasure(atMeasure(0, 2)), Companion.get_0()).execute();
    new MeasureElementWrite(new Dynamic(f), score.getMeasure(atMeasure(0, 3)), Companion.get_1$2()).execute();
    new MeasureElementWrite(w = new Wedge(Crescendo), score.getMeasure(atMeasure(0, 3)), Companion.get_3$4()).execute();
    new MeasureElementWrite(new WedgeEnd(w), score.getMeasure(atMeasure(0, 4)), Companion.get_1$4()).execute();
    new MeasureElementWrite(new Dynamic(pp), score.getMeasure(atMeasure(0, 4)), Companion.get_1$2()).execute();
    // voice 0
    val cursor = new Cursor(score, mp0, true);
    cursor.write(new Rest(Companion.get_1()));
    cursor.write(new Rest(Companion.get_1()));
    cursor.write(new Rest(Companion.get_1()));
    cursor.write(new Rest(Companion.get_1()));
    // voice 1
    cursor.setMp(atElement(0, 0, 1, 0));
    cursor.write(new Rest(Companion.get_1$2()));
    val chord = chord(Companion.pi(0, 4), Companion.get_1$2());
    chord.addDirection(new Dynamic(mf));
    cursor.write(chord);
    cursor.write(new Rest(Companion.get_1()));
    cursor.write(new Rest(Companion.get_1()));
    cursor.setMp(atElement(0, 4, 1, 0));
    cursor.write(new Rest(Companion.get_1()));
    // staff 1
    new MeasureElementWrite(new Dynamic(ff), score.getMeasure(atMeasure(1, 0)), Companion.get_0()).execute();
    new MeasureElementWrite(w = new Wedge(Diminuendo), score.getMeasure(atMeasure(1, 0)), Companion.get_0()).execute();
    new MeasureElementWrite(new WedgeEnd(w), score.getMeasure(atMeasure(1, 2)), Companion.get_0()).execute();
    new MeasureElementWrite(new Dynamic(mp), score.getMeasure(atMeasure(1, 2)), Companion.get_0()).execute();
    new MeasureElementWrite(new Dynamic(p), score.getMeasure(atMeasure(1, 3)), Companion.get_0()).execute();
    return score;
}
Also used : lombok.val(lombok.val) Dynamic(com.xenoage.zong.core.music.direction.Dynamic) ColumnElementWrite(com.xenoage.zong.commands.core.music.ColumnElementWrite) Cursor(com.xenoage.zong.io.selection.Cursor) Wedge(com.xenoage.zong.core.music.direction.Wedge) TimeSignature(com.xenoage.zong.core.music.time.TimeSignature) Score(com.xenoage.zong.core.Score) MeasureAdd(com.xenoage.zong.commands.core.music.MeasureAdd) Rest(com.xenoage.zong.core.music.rest.Rest) Part(com.xenoage.zong.core.music.Part) PartAdd(com.xenoage.zong.commands.core.music.PartAdd) MeasureElementWrite(com.xenoage.zong.commands.core.music.MeasureElementWrite) WedgeEnd(com.xenoage.zong.core.music.direction.WedgeEnd)

Aggregations

Dynamic (com.xenoage.zong.core.music.direction.Dynamic)2 WedgeEnd (com.xenoage.zong.core.music.direction.WedgeEnd)2 lombok.val (lombok.val)2 MaybeNull (com.xenoage.utils.annotations.MaybeNull)1 ColumnElementWrite (com.xenoage.zong.commands.core.music.ColumnElementWrite)1 MeasureAdd (com.xenoage.zong.commands.core.music.MeasureAdd)1 MeasureElementWrite (com.xenoage.zong.commands.core.music.MeasureElementWrite)1 PartAdd (com.xenoage.zong.commands.core.music.PartAdd)1 Score (com.xenoage.zong.core.Score)1 Part (com.xenoage.zong.core.music.Part)1 Wedge (com.xenoage.zong.core.music.direction.Wedge)1 Rest (com.xenoage.zong.core.music.rest.Rest)1 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)1 GradientDynamics (com.xenoage.zong.io.midi.out.dynamics.type.GradientDynamics)1 Cursor (com.xenoage.zong.io.selection.Cursor)1