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);
}
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);
}
}
}
}
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);
}
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);
}
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;
}
Aggregations