use of com.xenoage.zong.core.music.direction.Direction 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.Direction in project Zong by Xenoage.
the class Test31a method test.
@ToDo("add support for multiple direction-types within a single MusicXML direction")
@Test
public void test() {
Score score = getScore();
// test directions
for (Tuple2<MP, ?> item : expectedDirections) {
MP mp = item.get1();
List<?> directions = null;
// in the column header instead, and not in the measure
if (item.get2() instanceof Tempo)
directions = score.getColumnHeader(mp.measure).getTempos().getAll(mp.beat);
else if (item.get2() instanceof NavigationSign)
directions = score.getColumnHeader(mp.measure).getOtherDirections().getAll(mp.beat);
else
directions = score.getMeasure(mp).getDirections().getAll(mp.beat);
// check correct classes
if (item.get2() instanceof Direction) {
// single direction at this beat expected
assertEquals("" + mp, 1, directions.size());
assertEquals("" + mp, item.get2().getClass(), directions.get(0).getClass());
} else if (item.get2() instanceof List<?>) {
// List<?> l = (List<?>) item.get2();
// multiple directions at this beat expected
// TODO: add support for multiple direction-types within a single MusicXML direction
// assertEquals(""+mp, l.size(), directions.size());
// for (int i : range(l))
// assertEquals(""+mp+"["+i+"]", l.get(i).getClass(), directions.get(i).getClass());
}
}
// segno and coda
assertEquals(MusicElementType.Segno, score.getColumnHeader(1).getNavigationTarget().getMusicElementType());
assertEquals(MusicElementType.Coda, score.getColumnHeader(1).getNavigationOrigin().getMusicElementType());
}
use of com.xenoage.zong.core.music.direction.Direction in project Zong by Xenoage.
the class Test32a method test.
@Test
public void test() {
Score score = getScore();
for (Tuple2<MP, ?> item : expectedAnnotations) {
MP mp = item.get1();
List<?> annotations = null;
Chord chord = (Chord) score.getVoice(mp).getElementAt(mp.beat);
assertNotNull("" + mp, chord);
// in this test, the chords contain either directions or annotations
if (false == chord.getDirections().isEmpty())
annotations = chord.getDirections();
else
annotations = chord.getAnnotations();
// check correct classes
if (item.get2() instanceof Direction) {
// single direction at this beat expected
assertEquals("" + mp, 1, annotations.size());
assertEquals("" + mp, item.get2().getClass(), annotations.get(0).getClass());
} else if (item.get2() instanceof List<?>) {
// list of annotations
// we ignore the order here (MusicXML does not contain a order)
assertEquals("" + mp, set((List<?>) item.get2()), set(annotations));
} else {
// single annotation
assertEquals("" + mp, 1, annotations.size());
assertEquals("" + mp, item.get2(), annotations.get(0));
}
}
}
use of com.xenoage.zong.core.music.direction.Direction in project Zong by Xenoage.
the class Test32b method testStyle.
@Test
public void testStyle() {
Score score = getScore();
for (int i = 0; i < expectedTexts.size(); ) {
MP mp = expectedTexts.get(i).get1();
List<Direction> directions = score.getMeasure(mp).getDirections().getAll(mp.beat);
assertTrue("" + mp, directions.size() > 0);
for (val direction : directions) {
assertTrue("" + mp, direction instanceof Words);
check((Words) direction, expectedTexts.get(i).get2(), mp);
i++;
}
}
}
use of com.xenoage.zong.core.music.direction.Direction in project Zong by Xenoage.
the class Test21d method test.
@Test
public void test() {
MxlPart part = getFirstPart();
List<Tuple2<MP, ? extends Direction>> expectedDirections = getExpectedDirections();
// check only directions in this test
int iDirection = 0;
for (int iMeasure = 0; iMeasure <= 1; iMeasure++) {
MxlMeasure measure = part.getMeasures().get(iMeasure);
for (MxlMusicDataContent data : measure.getMusicData().getContent()) {
if (data.getMusicDataContentType() == MxlMusicDataContentType.Direction) {
// check type
MxlDirection dir = (MxlDirection) data;
MxlDirectionTypeContent content = dir.getDirectionTypes().get(0).getContent();
if (iDirection == 0) {
// Words "Largo"
assertEquals(0, iMeasure);
assertEquals(MxlDirectionTypeContentType.Words, content.getDirectionTypeContentType());
assertEquals("Largo", ((MxlWords) content).getFormattedText().getValue());
} else if (iDirection == 1) {
// Dynamic "fp"
assertEquals(0, iMeasure);
assertEquals(MxlDirectionTypeContentType.Dynamics, content.getDirectionTypeContentType());
assertEquals(DynamicValue.fp, ((MxlDynamics) content).getElement());
} else if (iDirection == 2) {
// Dynamic "p"
assertEquals(1, iMeasure);
assertEquals(MxlDirectionTypeContentType.Dynamics, content.getDirectionTypeContentType());
assertEquals(DynamicValue.p, ((MxlDynamics) content).getElement());
}
iDirection++;
}
}
}
assertEquals("not all directions found", expectedDirections.size(), iDirection);
}
Aggregations