use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class Test21c method test.
@Test
public void test() {
Score score = getScore();
MP mp = mp0;
for (int i = 0; i < expectedChords.length; i++) {
Chord chord = (Chord) score.getVoice(mp).getElementAt(mp.beat);
assertEquals("chord " + i, expectedChords[i].getNotes(), chord.getNotes());
assertEquals("chord " + i, expectedChords[i].getDuration(), chord.getDuration());
mp = mp.withBeat(mp.beat.add(expectedChords[i].getDuration()));
if (mp.beat.compareTo(Companion.get_1()) >= 0) {
mp = mp.withMeasure(mp.measure + 1).withBeat(Companion.get_0());
}
}
}
use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class Test21d method testMeasure1.
@Test
public void testMeasure1() {
MP m2 = mp0.withMeasure(1);
// chords
Chord chord = (Chord) score.getVoice(m2).getElementAt(Companion.get_0());
assertEquals(2, chord.getNotes().size());
assertEquals(Companion.pi('F', 0, 4), chord.getNotes().get(0).getPitch());
assertEquals(Companion.pi('A', -1, 4), chord.getNotes().get(1).getPitch());
assertEquals(Companion.fr(3, 8), chord.getDuration());
chord = (Chord) score.getVoice(m2).getElementAt(Companion.fr(3, 8));
assertEquals(2, chord.getNotes().size());
assertEquals(Companion.pi('F', 0, 4), chord.getNotes().get(0).getPitch());
assertEquals(Companion.pi('A', -1, 4), chord.getNotes().get(1).getPitch());
assertEquals(Companion.fr(1, 8), chord.getDuration());
chord = (Chord) score.getVoice(m2).getElementAt(Companion.fr(2, 4));
assertEquals(2, chord.getNotes().size());
assertEquals(Companion.pi('G', 0, 4), chord.getNotes().get(0).getPitch());
assertEquals(Companion.pi('B', -1, 4), chord.getNotes().get(1).getPitch());
assertEquals(Companion.fr(1, 4), chord.getDuration());
chord = (Chord) score.getVoice(m2).getElementAt(Companion.fr(3, 4));
assertEquals(2, chord.getNotes().size());
assertEquals(Companion.pi('G', 0, 4), chord.getNotes().get(0).getPitch());
assertEquals(Companion.pi('B', -1, 4), chord.getNotes().get(1).getPitch());
assertEquals(Companion.fr(1, 4), chord.getDuration());
// dynamics "p"
Dynamic dynamics = (Dynamic) score.getMeasure(m2).getMeasureElements().get(Companion.get_0());
assertEquals(DynamicValue.p, dynamics.getValue());
assertEquals(Placement.Below, dynamics.getPositioning());
}
use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class Test21f method test.
@Test
public void test() {
Score score = getScore();
// 1/4 with 3 notes at beat 0
List<VoiceElement> e = score.getVoice(mp0).getElements();
Chord chord = (Chord) e.get(0);
assertEquals(3, chord.getNotes().size());
assertEquals(Companion.fr(1, 4), chord.getDuration());
// followed by 2 rests, 1/4 and 2/4
assertEquals(Companion.fr(1, 4), ((Rest) e.get(1)).getDuration());
assertEquals(Companion.fr(2, 4), ((Rest) e.get(2)).getDuration());
// segno at beat 1/4 in column (moved to the end of the measure, since we accept no mid-measure segnos)
Direction segno = (Segno) score.getColumnHeader(0).getNavigationOrigin();
assertNotNull(segno);
// dynamics p at beat 1/4 in measure
Dynamic dynamics = (Dynamic) score.getMeasure(mp0).getDirections().get(Companion.fr(1, 4));
assertNotNull(dynamics);
assertEquals(DynamicValue.p, dynamics.getValue());
}
use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class Utils method gr.
/**
* Sets the given chord to a grace chord.
*/
public static Chord gr(Fraction graceDuration, boolean slash, Pitch... pitches) {
Grace grace = new Grace(slash, graceDuration);
ArrayList<Note> notes = alist();
for (Pitch pitch : pitches) notes.add(new Note(pitch));
return new Chord(notes, grace);
}
use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class VoiceTest method assertEqualsVoice.
/**
* Tests the equality of the given voices, but only the durations of the rests
* and the durations and notes of the chords.
*/
public static void assertEqualsVoice(Voice expectedVoice, Voice voice, MP voiceMP) {
assertEquals("" + voiceMP, expectedVoice.getElements().size(), voice.getElements().size());
for (int i : range(expectedVoice.getElements())) {
VoiceElement expElement = expectedVoice.getElement(i);
VoiceElement element = voice.getElement(i);
assertEquals(expElement.getClass(), element.getClass());
assertEquals(expElement.getDuration(), element.getDuration());
if (expElement instanceof Chord)
assertEqualsChord((Chord) expElement, (Chord) element, voiceMP.withElement(i));
}
}
Aggregations