Search in sources :

Example 1 with TimeType

use of com.xenoage.zong.core.music.time.TimeType 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);
}
Also used : MxlMusicDataContent(com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent) MxlAttributes(com.xenoage.zong.musicxml.types.MxlAttributes) MxlNormalTime(com.xenoage.zong.musicxml.types.MxlNormalTime) MxlPart(com.xenoage.zong.musicxml.types.partwise.MxlPart) MxlMeasure(com.xenoage.zong.musicxml.types.partwise.MxlMeasure) TimeType(com.xenoage.zong.core.music.time.TimeType) Test(org.junit.Test)

Aggregations

TimeType (com.xenoage.zong.core.music.time.TimeType)1 MxlAttributes (com.xenoage.zong.musicxml.types.MxlAttributes)1 MxlNormalTime (com.xenoage.zong.musicxml.types.MxlNormalTime)1 MxlMusicDataContent (com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent)1 MxlMeasure (com.xenoage.zong.musicxml.types.partwise.MxlMeasure)1 MxlPart (com.xenoage.zong.musicxml.types.partwise.MxlPart)1 Test (org.junit.Test)1