Search in sources :

Example 31 with Chord

use of com.xenoage.zong.core.music.chord.Chord 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 32 with Chord

use of com.xenoage.zong.core.music.chord.Chord 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 33 with Chord

use of com.xenoage.zong.core.music.chord.Chord 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 34 with Chord

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

the class Test21b method test.

@Test
public void test() {
    Score score = getScore();
    MP mp = mp0;
    for (int i = 0; i < expectedChordsCount; i++) {
        Chord chord = (Chord) score.getVoice(mp).getElementAt(mp.beat);
        assertEquals(expectedChord.getNotes(), chord.getNotes());
        assertEquals(expectedChord.getDuration(), chord.getDuration());
        mp = mp.withBeat(mp.beat.add(Companion.fr(1, 4)));
        if (mp.beat.compareTo(Companion.get_1()) >= 0) {
            mp = mp.withMeasure(mp.measure + 1).withBeat(Companion.get_0());
        }
    }
}
Also used : Score(com.xenoage.zong.core.Score) MP(com.xenoage.zong.core.position.MP) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 35 with Chord

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

the class Test21d method testMeasure0.

@Test
public void testMeasure0() {
    // F4, whole, with accent and fermata
    Chord chord = (Chord) score.getVoice(mp0).getElementAt(Companion.get_0());
    assertEquals(1, chord.getNotes().size());
    assertEquals(Companion.pi('F', 0, 4), chord.getNotes().get(0).getPitch());
    assertEquals(Companion.get_1(), chord.getDuration());
    assertEquals(2, chord.getAnnotations().size());
    assertEquals(articulation(ArticulationType.Accent, Placement.Below), chord.getAnnotations().get(0));
    assertEquals(fermata(Placement.Above), chord.getAnnotations().get(1));
    // words "Largo"
    List<MeasureElement> directions = score.getMeasure(mp0).getMeasureElements().getAll(Companion.get_0());
    // clef, words, dynamics
    assertEquals(3, directions.size());
    Words words = (Words) directions.get(1);
    assertEquals("Largo", words.getText().toString());
    assertEquals(Placement.Above, words.getPositioning());
    // dynamics "fp"
    Dynamic dynamics = (Dynamic) directions.get(2);
    assertEquals(DynamicValue.fp, dynamics.getValue());
    assertEquals(Placement.Below, dynamics.getPositioning());
}
Also used : MeasureElement(com.xenoage.zong.core.music.MeasureElement) Dynamic(com.xenoage.zong.core.music.direction.Dynamic) Words(com.xenoage.zong.core.music.direction.Words) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Aggregations

Chord (com.xenoage.zong.core.music.chord.Chord)63 Test (org.junit.Test)34 MP (com.xenoage.zong.core.position.MP)16 Pitch (com.xenoage.zong.core.music.Pitch)12 Score (com.xenoage.zong.core.Score)11 Voice (com.xenoage.zong.core.music.Voice)10 NotesNotation (com.xenoage.zong.musiclayout.notation.chord.NotesNotation)10 VoiceElement (com.xenoage.zong.core.music.VoiceElement)8 Note (com.xenoage.zong.core.music.chord.Note)6 Rest (com.xenoage.zong.core.music.rest.Rest)6 ChordTest (musicxmltestsuite.tests.utils.ChordTest)6 Fraction (com.xenoage.utils.math.Fraction)5 Staff (com.xenoage.zong.core.music.Staff)4 Beam (com.xenoage.zong.core.music.beam.Beam)4 Grace (com.xenoage.zong.core.music.chord.Grace)4 StemDirection (com.xenoage.zong.core.music.chord.StemDirection)4 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)4 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)4 ChordNotation (com.xenoage.zong.musiclayout.notation.ChordNotation)4 NoteDisplacement (com.xenoage.zong.musiclayout.notation.chord.NoteDisplacement)4