use of com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent in project Zong by Xenoage.
the class Test13a method test.
@ToDo("Zong! supports only -7 to +7, starting in measure 9, ending in measure 38")
@Test
public void test() {
MxlPart part = getFirstPart();
TraditionalKey[] expectedKeys = getExpectedKeys();
int iKey = 0;
for (int i = 8; i <= 37; i++) {
MxlMeasure measure = part.getMeasures().get(i);
for (MxlMusicDataContent data : measure.getMusicData().getContent()) {
if (data.getMusicDataContentType() == MxlMusicDataContentType.Attributes) {
// check type
MxlAttributes attr = (MxlAttributes) data;
MxlKey key = attr.getKey();
assertEquals(expectedKeys[iKey].getFifths(), key.getFifths());
assertEquals(expectedKeys[iKey].getMode(), getEnumValue("" + key.getMode(), Mode.values()));
iKey++;
}
}
}
}
use of com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent in project Zong by Xenoage.
the class Test13b method test.
@Test
public void test() {
TraditionalKey[] expectedKeys = getExpectedKeys();
MxlPart part = getFirstPart();
int iKey = 0;
for (int i = 0; i <= 2; i++) {
MxlMeasure measure = part.getMeasures().get(i);
for (MxlMusicDataContent data : measure.getMusicData().getContent()) {
if (data.getMusicDataContentType() == MxlMusicDataContentType.Attributes) {
// check type
MxlAttributes attr = (MxlAttributes) data;
MxlKey key = attr.getKey();
assertEquals(expectedKeys[iKey].getFifths(), key.getFifths());
assertEquals(expectedKeys[iKey].getMode(), getEnumValue("" + key.getMode(), Mode.values()));
iKey++;
if (iKey >= expectedKeys.length)
break;
}
}
}
assertEquals("not all keys found", expectedKeys.length, iKey);
}
use of com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent 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.choice.MxlMusicDataContent in project Zong by Xenoage.
the class Test01b method test.
@Test
public void test() {
Pitch[] expectedPitches = getExpectedPitches();
MxlPart part = getFirstPart();
int iPitch = 0;
for (int iM = 0; iM < part.getMeasures().size(); iM++) {
MxlMeasure measure = part.getMeasures().get(iM);
for (MxlMusicDataContent data : measure.getMusicData().getContent()) {
if (data.getMusicDataContentType() == MxlMusicDataContentType.Note) {
// check note and pitch
MxlFullNote note = ((MxlNote) data).getContent().getFullNote();
MxlPitch pitch = (MxlPitch) (note.getContent());
assertEquals("note " + iPitch, expectedPitches[iPitch++], pitch.getPitch());
}
}
}
assertEquals("not all notes found", expectedPitches.length, iPitch);
}
use of com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent in project Zong by Xenoage.
the class StavesListReader method countStaves.
/**
* Counts the number of staves used in each part and returns them.
* @return a hashmap which maps a part ID to the number of staves in this part
*/
private HashMap<String, Integer> countStaves(MxlScorePartwise mxlScore) {
HashMap<String, Integer> ret = map();
// check all parts
for (MxlPart mxlPart : mxlScore.getParts()) {
String id = mxlPart.getId();
// heck all measures for attributes with staves-element and store the greatest value
int maxStaves = 1;
for (MxlMeasure mxlMeasure : mxlPart.getMeasures()) {
for (MxlMusicDataContent content : mxlMeasure.getMusicData().getContent()) {
if (content.getMusicDataContentType() == MxlMusicDataContentType.Attributes) {
Integer xmlStaves = ((MxlAttributes) content).getStaves();
if (xmlStaves != null) {
maxStaves = Math.max(maxStaves, xmlStaves);
}
}
}
}
// set the number of staves of the part
ret.put(id, maxStaves);
}
return ret;
}
Aggregations