use of com.xenoage.zong.core.music.direction.Wedge in project Zong by Xenoage.
the class WedgeStamper method stampSystem.
/**
* Creates all wedge stampings in the given system.
* @param openWedges input and output parameter: voltas, which are still open from the
* last system. After the method returns, it contains the voltas which
* are still open after this system
*/
public List<WedgeStamping> stampSystem(SystemSpacing system, Score score, StaffStampings staffStampings, OpenWedges openWedges) {
List<WedgeStamping> ret = alist();
// find new wedges beginning in this staff
for (int iStaff : range(score.getStavesCount())) {
Staff staff = score.getStaff(iStaff);
for (int iMeasure : system.getMeasures()) {
Measure measure = staff.getMeasure(iMeasure);
for (BeatE<Direction> dir : measure.getDirections()) {
if (dir.getElement() instanceof Wedge) {
Wedge wedge = (Wedge) dir.getElement();
// if the position of the end element is known
if (wedge.getWedgeEnd().getMP() != null)
openWedges.wedges.add(new ContinuedWedge((Wedge) dir.getElement()));
}
}
}
}
// draw wedges in the cache, and remove them if closed in this system
for (Iterator<ContinuedWedge> itW = openWedges.wedges.iterator(); itW.hasNext(); ) {
ContinuedWedge wedge = itW.next();
ret.add(stamp(wedge.element, staffStampings.get(system.getSystemIndexInFrame(), wedge.element.getMP().staff)));
if (MP.getMP(wedge.element.getWedgeEnd()).measure <= system.getEndMeasure()) {
// wedge is closed
itW.remove();
}
}
return ret;
}
use of com.xenoage.zong.core.music.direction.Wedge in project Zong by Xenoage.
the class DynamicsFinder method getStaffDynamicStartAt.
/**
* Returns the {@link DynamicsType} starting at the given time within the given staff (not a voice),
* or null, if nothing starts here.
*/
@MaybeNull
private DynamicsType getStaffDynamicStartAt(int staff, Time time, DynamicValue currentDynamicValue) {
val measure = score.getMeasure(atMeasure(staff, time.getMeasure()));
// when there is a Wedge (possible with a Dynamic as the start volume), create
// a gradient dynamic, when there is only a Dynamic, create a fixed dynamic
val foundDynamic = (Dynamic) measure.getDirections().get(time.getBeat(), MusicElementType.Dynamic);
val foundWedge = (Wedge) measure.getDirections().get(time.getBeat(), MusicElementType.Wedge);
if (foundWedge != null) {
// gradient
val startDynamicValue = (foundDynamic != null ? foundDynamic.getValue() : currentDynamicValue);
val endDynamicValue = startDynamicValue.getWedgeEndValue(foundWedge.getType());
// can be replaced later, when end dynamic is found
return new GradientDynamics(startDynamicValue, endDynamicValue);
} else if (foundDynamic != null) {
// fixed value
return new FixedDynamics(foundDynamic.getValue());
}
return null;
}
use of com.xenoage.zong.core.music.direction.Wedge in project Zong by Xenoage.
the class Base43e method getExpectedDirections.
static List<Tuple2<MP, Direction>> getExpectedDirections() {
Wedge wedge;
List<Tuple2<MP, Direction>> directions = alist();
directions.add(t(atBeat(0, 0, unknown, Companion.get_0()), new Dynamic(DynamicValue.ffff)));
directions.add(t(atBeat(0, 0, unknown, Companion.fr(3, 4)), new Dynamic(DynamicValue.p)));
directions.add(t(atBeat(1, 0, unknown, Companion.get_0()), wedge = new Wedge(WedgeType.Crescendo)));
directions.add(t(atBeat(1, 0, unknown, Companion.fr(2, 4)), wedge.getWedgeEnd()));
return directions;
}
use of com.xenoage.zong.core.music.direction.Wedge 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;
}
use of com.xenoage.zong.core.music.direction.Wedge in project Zong by Xenoage.
the class Context method openWedge.
/**
* Sets the beginning of a wedge with the given number.
* When there is still an open wedge with this number, it
* is removed from the score.
*/
public void openWedge(int number, Wedge wedge) {
if (false == checkNumber1to6(number))
return;
// remove existing open wedge
Wedge openWedge = openElements.getOpenWedges().get(number - 1);
if (openWedge != null)
removeUnclosedWedge(openWedge);
// add new wedge
List<Wedge> openWedges = openElements.getOpenWedges();
openWedges.set(number - 1, wedge);
}
Aggregations