use of com.xenoage.zong.musicxml.types.MxlDynamics 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);
}
use of com.xenoage.zong.musicxml.types.MxlDynamics in project Zong by Xenoage.
the class NotationsReader method readToNote.
public void readToNote(Chord chord, int noteIndex, int staffIndexInPart, Context context) {
StaffDetails staffDetails = StaffDetails.fromContext(context, staffIndexInPart);
ArrayList<Annotation> annotations = alist(0);
for (MxlNotations mxlNotationsElement : mxlNotations) {
for (MxlNotationsContent mxlNC : mxlNotationsElement.getElements()) {
MxlNotationsContentType mxlNCType = mxlNC.getNotationsContentType();
switch(mxlNCType) {
case SlurOrTied:
{
SlurReader.readToContext(chord, noteIndex, staffIndexInPart, context, (MxlSlurOrTied) mxlNC);
break;
}
case Dynamics:
{
Dynamic dynamics = DynamicsReader.read((MxlDynamics) mxlNC, staffDetails);
new DirectionAdd(dynamics, chord).execute();
break;
}
case Articulations:
{
MxlArticulations mxlArticulations = (MxlArticulations) mxlNC;
annotations.addAll(ArticulationReader.read(mxlArticulations));
break;
}
case Fermata:
{
Fermata fermata = FermataReader.read((MxlFermata) mxlNC, staffDetails);
annotations.add(fermata);
break;
}
case Ornaments:
{
MxlOrnaments mxlOrnaments = (MxlOrnaments) mxlNC;
annotations.addAll(OrnamentReader.read(mxlOrnaments));
break;
}
default:
}
}
}
if (annotations.size() > 0)
chord.setAnnotations(annotations);
}
Aggregations