use of com.xenoage.zong.musicxml.types.partwise.MxlPart in project Zong by Xenoage.
the class MxlScorePartwise method read.
@NonNull
public static MxlScorePartwise read(XmlReader reader, ErrorHandler errorHandler) {
// attributes
String version = notNull(reader.getAttribute("version"), defaultVersion);
// elements
MxlScoreHeader scoreHeader = new MxlScoreHeader();
List<MxlPart> parts = alist();
while (reader.openNextChildElement()) {
if (reader.getElementName().equals(MxlPart.elemName))
parts.add(MxlPart.read(reader));
else
scoreHeader.readElement(reader, errorHandler);
reader.closeElement();
}
scoreHeader.check(reader);
if (parts.size() < 1)
throw reader.dataException("no parts found");
return new MxlScorePartwise(scoreHeader, parts, version);
}
use of com.xenoage.zong.musicxml.types.partwise.MxlPart in project Zong by Xenoage.
the class Test02a method test.
@ToDo("multirests are not supported yet")
@Test
public void test() {
MxlPart part = getFirstPart();
int iDuration = 0;
// from MusicXML file
int divisions = 64;
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 type and duration
MxlNormalNote note = (MxlNormalNote) ((MxlNote) data).getContent();
assertEquals(MxlFullNoteContentType.Rest, note.getFullNote().getContent().getFullNoteContentType());
assertEquals("rest " + iDuration, expectedDurations[iDuration++], Companion.fr(note.getDuration(), divisions * 4));
}
}
}
assertEquals("not all rests found", expectedDurations.length, iDuration);
}
use of com.xenoage.zong.musicxml.types.partwise.MxlPart in project Zong by Xenoage.
the class Test03a method test.
@ToDo("multiple-rest not yet supported")
@Test
public void test() {
MxlPart part = getFirstPart();
int iDuration = 0;
// from MusicXML file
int divisions = 64;
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 type and duration
MxlNormalNote note = (MxlNormalNote) ((MxlNote) data).getContent();
assertEquals(MxlFullNoteContentType.Pitch, note.getFullNote().getContent().getFullNoteContentType());
assertEquals("note " + iDuration, expectedDurations[iDuration++], Companion.fr(note.getDuration(), divisions * 4));
}
}
}
assertEquals("not all notes found", expectedDurations.length, iDuration);
}
use of com.xenoage.zong.musicxml.types.partwise.MxlPart in project Zong by Xenoage.
the class Test11a method test.
@Test
public void test() {
MxlPart part = getFirstPart();
int iTime = 0;
for (int i = 0; i < part.getMeasures().size(); i++) {
MxlMeasure measure = part.getMeasures().get(i);
for (MxlMusicDataContent data : measure.getMusicData().getContent()) {
if (data.getMusicDataContentType() == MxlMusicDataContentType.Attributes) {
// check type
MxlAttributes attr = (MxlAttributes) data;
MxlNormalTime mxlTime = (MxlNormalTime) attr.getTime().getContent();
TimeType expectedTime = expectedTimes[iTime++];
assertEquals("time " + iTime, expectedTime.getNumerator(), mxlTime.getBeats());
assertEquals("time " + iTime, expectedTime.getDenominator(), mxlTime.getBeatType());
if (i == 0)
// TODO: bug in MusicXML file, should be "Cut"
assertEquals("time " + iTime, MxlTimeSymbol.Common, attr.getTime().getSymbol());
else if (i == 1)
assertEquals("time " + iTime, MxlTimeSymbol.Common, attr.getTime().getSymbol());
else
// = Normal
assertNull("time " + iTime, attr.getTime().getSymbol());
// no more time signature in this measure
break;
}
}
}
assertEquals("not all times found", expectedTimes.length, iTime);
}
use of com.xenoage.zong.musicxml.types.partwise.MxlPart 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++;
}
}
}
}
Aggregations