Search in sources :

Example 11 with Chord

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

the class Test61i method test.

@Test
public void test() {
    MP mp = MP.atElement(0, 0, 0, 0);
    Chord chord = ChordTest.getChordAt(score, mp);
    assertEquals(expectedChordNotesCount[0], chord.getNotes().size());
    assertEqualsChordLyrics(expectedLyrics[0], chord, mp);
}
Also used : MP(com.xenoage.zong.core.position.MP) Chord(com.xenoage.zong.core.music.chord.Chord) ChordTest(musicxmltestsuite.tests.utils.ChordTest) Test(org.junit.Test)

Example 12 with Chord

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

the class Test72a method testNotatedPitches.

@Test
public void testNotatedPitches() {
    for (int iStaff : range(3)) {
        for (int iMeasure : range(2)) {
            for (int iElement : range(4)) {
                MP mp = MP.atElement(iStaff, iMeasure, 0, iElement);
                Chord chord = getChordAt(score, mp);
                Pitch pitch = chord.getNotes().get(0).getPitch();
                assertEquals("" + mp, expectedNotatedPitches[iStaff][iMeasure * 4 + iElement], pitch);
            }
        }
    }
}
Also used : MP(com.xenoage.zong.core.position.MP) Pitch(com.xenoage.zong.core.music.Pitch) Chord(com.xenoage.zong.core.music.chord.Chord) Test(org.junit.Test)

Example 13 with Chord

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

the class Utils method checkGraceChords.

public static void checkGraceChords(Staff staff, Chord[] expectedChords, boolean skipRests) {
    int iChord = 0;
    for (int iM = 0; iM < staff.getMeasures().size(); iM++) {
        Voice voice = staff.getMeasure(iM).getVoice(0);
        for (VoiceElement e : voice.getElements()) {
            if (e instanceof Rest && skipRests)
                continue;
            // check duration, type and notes
            Chord chord = (Chord) e;
            Chord expectedChord = expectedChords[iChord];
            assertEquals("chord " + iChord, expectedChord.getDuration(), chord.getDuration());
            assertEquals("chord " + iChord, expectedChord.getGrace(), chord.getGrace());
            assertEquals("chord " + iChord, expectedChord.getNotes(), chord.getNotes());
            iChord++;
        }
    }
    assertEquals("not all chords found", expectedChords.length, iChord);
}
Also used : Rest(com.xenoage.zong.core.music.rest.Rest) VoiceElement(com.xenoage.zong.core.music.VoiceElement) Voice(com.xenoage.zong.core.music.Voice) Chord(com.xenoage.zong.core.music.chord.Chord) SlurWaypoint(com.xenoage.zong.core.music.slur.SlurWaypoint)

Example 14 with Chord

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

the class OpenUnnumberedTieds method startTied.

/**
 * Starts a tie.
 */
public void startTied(SlurWaypoint wp, VSide side) {
    Chord chord = wp.getChord();
    Pitch pitch = chord.getNotes().get(wp.getNoteIndex()).getPitch();
    // already a tied open for this pitch? then remember it, too
    if (openTieds.get(pitch) != null)
        openEarlierTieds.put(pitch, openTieds.get(pitch));
    // add new tied
    OpenSlur openTied = new OpenSlur();
    openTied.type = SlurType.Tie;
    openTied.start = new OpenSlur.Waypoint(wp, side);
    openTieds.put(pitch, openTied);
}
Also used : Pitch(com.xenoage.zong.core.music.Pitch) Chord(com.xenoage.zong.core.music.chord.Chord)

Example 15 with Chord

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

the class OpenUnnumberedTieds method stopTied.

/**
 * Ends an existing tie and returns the {@link OpenSlur}.
 * When the tie does not exist, null is returned.
 */
public OpenSlur stopTied(SlurWaypoint wp, VSide side, Context context) {
    Chord chord = wp.getChord();
    Pitch pitch = chord.getNotes().get(wp.getNoteIndex()).getPitch();
    // get tied for this pitch
    OpenSlur openTied = openTieds.remove(pitch);
    if (openTied == null) {
        context.reportError("Can not stop non-existing tied");
        return null;
    }
    // does start chord exist? could have been overwritten by backup element
    MP startMp = openTied.start.wp.getChord().getMP();
    if (startMp == null) {
        context.reportError("Tied can not be closed; start chord does not exist");
        return null;
    }
    // then close the earlier open tied instead, if there is one
    if (startMp.equals(context.getMp())) {
        // remember last tied
        openTieds.put(pitch, openTied);
        // use earlier tied instead
        openTied = openEarlierTieds.remove(pitch);
        if (openTied == null) {
            context.reportError("Tied can not be stopped on starting position, " + "and there is no earlier tied");
            return null;
        }
    }
    openTied.stop = new OpenSlur.Waypoint(wp, side);
    return openTied;
}
Also used : MP(com.xenoage.zong.core.position.MP) Pitch(com.xenoage.zong.core.music.Pitch) Chord(com.xenoage.zong.core.music.chord.Chord)

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