Search in sources :

Example 1 with MxlMeasure

use of com.xenoage.zong.musicxml.types.partwise.MxlMeasure 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);
}
Also used : MxlMusicDataContent(com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent) MxlPart(com.xenoage.zong.musicxml.types.partwise.MxlPart) MxlNormalNote(com.xenoage.zong.musicxml.types.choice.MxlNormalNote) MxlMeasure(com.xenoage.zong.musicxml.types.partwise.MxlMeasure) ToDo(musicxmltestsuite.tests.utils.ToDo) Test(org.junit.Test)

Example 2 with MxlMeasure

use of com.xenoage.zong.musicxml.types.partwise.MxlMeasure 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);
}
Also used : MxlMusicDataContent(com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent) MxlPart(com.xenoage.zong.musicxml.types.partwise.MxlPart) MxlNormalNote(com.xenoage.zong.musicxml.types.choice.MxlNormalNote) MxlMeasure(com.xenoage.zong.musicxml.types.partwise.MxlMeasure) ToDo(musicxmltestsuite.tests.utils.ToDo) Test(org.junit.Test)

Example 3 with MxlMeasure

use of com.xenoage.zong.musicxml.types.partwise.MxlMeasure 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)

Example 4 with MxlMeasure

use of com.xenoage.zong.musicxml.types.partwise.MxlMeasure 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++;
            }
        }
    }
}
Also used : MxlMusicDataContent(com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent) MxlAttributes(com.xenoage.zong.musicxml.types.MxlAttributes) MxlPart(com.xenoage.zong.musicxml.types.partwise.MxlPart) TraditionalKey(com.xenoage.zong.core.music.key.TraditionalKey) MxlKey(com.xenoage.zong.musicxml.types.MxlKey) MxlMeasure(com.xenoage.zong.musicxml.types.partwise.MxlMeasure) ToDo(musicxmltestsuite.tests.utils.ToDo) Test(org.junit.Test)

Example 5 with MxlMeasure

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

Aggregations

MxlMeasure (com.xenoage.zong.musicxml.types.partwise.MxlMeasure)12 MxlMusicDataContent (com.xenoage.zong.musicxml.types.choice.MxlMusicDataContent)11 MxlPart (com.xenoage.zong.musicxml.types.partwise.MxlPart)10 Test (org.junit.Test)10 ToDo (musicxmltestsuite.tests.utils.ToDo)4 TraditionalKey (com.xenoage.zong.core.music.key.TraditionalKey)3 MxlAttributes (com.xenoage.zong.musicxml.types.MxlAttributes)3 MxlPitch (com.xenoage.zong.musicxml.types.MxlPitch)3 MxlFullNote (com.xenoage.zong.musicxml.types.groups.MxlFullNote)3 Pitch (com.xenoage.zong.core.music.Pitch)2 MxlKey (com.xenoage.zong.musicxml.types.MxlKey)2 MxlNormalNote (com.xenoage.zong.musicxml.types.choice.MxlNormalNote)2 Tuple2 (com.xenoage.utils.kernel.Tuple2)1 Fraction (com.xenoage.utils.math.Fraction)1 ColumnElementWrite (com.xenoage.zong.commands.core.music.ColumnElementWrite)1 MeasureAddUpTo (com.xenoage.zong.commands.core.music.MeasureAddUpTo)1 MeasureElementWrite (com.xenoage.zong.commands.core.music.MeasureElementWrite)1 VoiceElementWrite (com.xenoage.zong.commands.core.music.VoiceElementWrite)1 Measure (com.xenoage.zong.core.music.Measure)1 Part (com.xenoage.zong.core.music.Part)1