Search in sources :

Example 6 with VoiceElement

use of com.xenoage.zong.core.music.VoiceElement in project Zong by Xenoage.

the class Test24a method testBeams.

@Test
public void testBeams() {
    Staff staff = getFirstStaff();
    int iChord = 0;
    Beam currentBeam = null;
    for (int iM = 0; iM < staff.getMeasures().size(); iM++) {
        Voice voice = staff.getMeasure(iM).getVoice(0);
        for (VoiceElement e : voice.getElements()) {
            Chord expectedChord = expectedChords[iChord];
            // beams between chord 2 and 3 and between 11 and 12
            if (iChord == 2 || iChord == 11) {
                assertNotNull("chord " + iChord + " unbeamed", expectedChord.getBeam());
                assertEquals("chord " + iChord, WaypointPosition.Start, expectedChord.getBeam().getWaypointPosition(expectedChord));
                currentBeam = expectedChord.getBeam();
            } else if (iChord == 3 || iChord == 12) {
                assertNotNull("chord " + iChord + " unbeamed", expectedChord.getBeam());
                assertEquals("wrong beam", currentBeam, expectedChord.getBeam());
                assertEquals("chord " + iChord, WaypointPosition.Stop, expectedChord.getBeam().getWaypointPosition(expectedChord));
                currentBeam = null;
            } else {
                assertNull("chord " + iChord + " beamed", expectedChord.getBeam());
            }
            iChord++;
        }
    }
    assertEquals("not all chords found", expectedChords.length, iChord);
}
Also used : Beam(com.xenoage.zong.core.music.beam.Beam) VoiceElement(com.xenoage.zong.core.music.VoiceElement) Staff(com.xenoage.zong.core.music.Staff) Voice(com.xenoage.zong.core.music.Voice) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 7 with VoiceElement

use of com.xenoage.zong.core.music.VoiceElement in project Zong by Xenoage.

the class Test01a method test.

@ToDo("the editiorial sharp (sharp in parenthesis) in the last measure is not supported yet")
@Test
public void test() {
    Pitch[] expectedPitches = getExpectedPitches();
    Staff staff = getFirstStaff();
    assertEquals(26, staff.getMeasures().size());
    int iPitch = 0;
    for (int iM = 0; iM < staff.getMeasures().size(); iM++) {
        Measure measure = staff.getMeasures().get(iM);
        Voice voice = measure.getVoice(0);
        for (VoiceElement e : voice.getElements()) {
            if (e instanceof Chord) {
                // check note and pitch
                Chord chord = (Chord) e;
                assertEquals(expectedPitches[iPitch++], chord.getNotes().get(0).getPitch());
            }
        }
    }
    assertEquals("not all notes found", expectedPitches.length, iPitch);
}
Also used : VoiceElement(com.xenoage.zong.core.music.VoiceElement) Staff(com.xenoage.zong.core.music.Staff) Pitch(com.xenoage.zong.core.music.Pitch) Measure(com.xenoage.zong.core.music.Measure) Voice(com.xenoage.zong.core.music.Voice) Chord(com.xenoage.zong.core.music.chord.Chord) ToDo(musicxmltestsuite.tests.utils.ToDo) Test(org.junit.Test)

Example 8 with VoiceElement

use of com.xenoage.zong.core.music.VoiceElement in project Zong by Xenoage.

the class Test01b method test.

@Test
public void test() {
    Pitch[] expectedPitches = getExpectedPitches();
    int iPitch = 0;
    Staff staff = getFirstStaff();
    for (int iM = 0; iM < staff.getMeasures().size(); iM++) {
        Measure measure = staff.getMeasures().get(iM);
        Voice voice = measure.getVoice(0);
        for (VoiceElement e : voice.getElements()) {
            if (e instanceof Chord) {
                // check note and pitch
                Chord chord = (Chord) e;
                assertEquals(expectedPitches[iPitch++], chord.getNotes().get(0).getPitch());
            }
        }
    }
// TODO - ignore this test, since MusicXML input file has a bug (only a single measure),
// so currently only the first measure is tested
// assertEquals("not all notes found", expectedPitches.length, iPitch);
}
Also used : VoiceElement(com.xenoage.zong.core.music.VoiceElement) Staff(com.xenoage.zong.core.music.Staff) Pitch(com.xenoage.zong.core.music.Pitch) Measure(com.xenoage.zong.core.music.Measure) Voice(com.xenoage.zong.core.music.Voice) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 9 with VoiceElement

use of com.xenoage.zong.core.music.VoiceElement in project Zong by Xenoage.

the class Test01a method test.

@ToDo("the editiorial sharp (sharp in parenthesis) in the last measure is not supported yet")
@Test
public void test() {
    int[] expectedLPs = getExpectedLPs();
    Staff staff = getFirstStaff();
    ScoreFrameLayout scoreFrameLayout = getScoreFrameLayout();
    int chordIndex = 0;
    for (int iM = 0; iM < staff.getMeasures().size(); iM++) {
        Measure measure = staff.getMeasures().get(iM);
        Voice voice = measure.getVoice(0);
        for (VoiceElement e : voice.getElements()) {
            if (e instanceof Chord) {
            // check LP
            // TODO
            }
        }
    }
}
Also used : VoiceElement(com.xenoage.zong.core.music.VoiceElement) Staff(com.xenoage.zong.core.music.Staff) Measure(com.xenoage.zong.core.music.Measure) ScoreFrameLayout(com.xenoage.zong.musiclayout.ScoreFrameLayout) Voice(com.xenoage.zong.core.music.Voice) Chord(com.xenoage.zong.core.music.chord.Chord) ToDo(musicxmltestsuite.tests.utils.ToDo) Test(org.junit.Test)

Example 10 with VoiceElement

use of com.xenoage.zong.core.music.VoiceElement in project Zong by Xenoage.

the class Test01c method test.

@Test
public void test() {
    Voice voice = getScore().getVoice(mp0);
    for (VoiceElement e : voice.getElements()) {
        if (e instanceof Chord) {
            Chord chord = (Chord) e;
            // check pitch
            assertEquals(Companion.pi('G', 0, 4), chord.getNotes().get(0).getPitch());
            // check lyric
            assertEquals(1, chord.getLyrics().size());
            assertEquals("A", chord.getLyrics().get(0).getText().toString());
            return;
        }
    }
    fail("note not found");
}
Also used : VoiceElement(com.xenoage.zong.core.music.VoiceElement) Voice(com.xenoage.zong.core.music.Voice) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Aggregations

VoiceElement (com.xenoage.zong.core.music.VoiceElement)17 Voice (com.xenoage.zong.core.music.Voice)12 Test (org.junit.Test)11 Chord (com.xenoage.zong.core.music.chord.Chord)8 ElementSpacing (com.xenoage.zong.musiclayout.spacing.ElementSpacing)6 VoiceSpacing (com.xenoage.zong.musiclayout.spacing.VoiceSpacing)6 ChordNotation (com.xenoage.zong.musiclayout.notation.ChordNotation)5 RestNotation (com.xenoage.zong.musiclayout.notation.RestNotation)5 ElementWidth (com.xenoage.zong.musiclayout.spacing.ElementWidth)5 Measure (com.xenoage.zong.core.music.Measure)4 Staff (com.xenoage.zong.core.music.Staff)4 VoiceTest (com.xenoage.zong.core.music.VoiceTest)4 Notations (com.xenoage.zong.musiclayout.notation.Notations)4 LayoutSettingsTest (com.xenoage.zong.musiclayout.settings.LayoutSettingsTest)4 Fraction (com.xenoage.utils.math.Fraction)3 Pitch (com.xenoage.zong.core.music.Pitch)2 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)2 ToDo (musicxmltestsuite.tests.utils.ToDo)2 Score (com.xenoage.zong.core.Score)1 MusicElement (com.xenoage.zong.core.music.MusicElement)1