use of com.xenoage.zong.core.music.direction.Dynamic in project Zong by Xenoage.
the class NotationsReader method readToNote.
public void readToNote(Chord chord, int noteIndex, int staffIndexInPart, Context context) {
StaffDetails staffDetails = StaffDetails.fromContext(context, staffIndexInPart);
ArrayList<Annotation> annotations = alist(0);
for (MxlNotations mxlNotationsElement : mxlNotations) {
for (MxlNotationsContent mxlNC : mxlNotationsElement.getElements()) {
MxlNotationsContentType mxlNCType = mxlNC.getNotationsContentType();
switch(mxlNCType) {
case SlurOrTied:
{
SlurReader.readToContext(chord, noteIndex, staffIndexInPart, context, (MxlSlurOrTied) mxlNC);
break;
}
case Dynamics:
{
Dynamic dynamics = DynamicsReader.read((MxlDynamics) mxlNC, staffDetails);
new DirectionAdd(dynamics, chord).execute();
break;
}
case Articulations:
{
MxlArticulations mxlArticulations = (MxlArticulations) mxlNC;
annotations.addAll(ArticulationReader.read(mxlArticulations));
break;
}
case Fermata:
{
Fermata fermata = FermataReader.read((MxlFermata) mxlNC, staffDetails);
annotations.add(fermata);
break;
}
case Ornaments:
{
MxlOrnaments mxlOrnaments = (MxlOrnaments) mxlNC;
annotations.addAll(OrnamentReader.read(mxlOrnaments));
break;
}
default:
}
}
}
if (annotations.size() > 0)
chord.setAnnotations(annotations);
}
use of com.xenoage.zong.core.music.direction.Dynamic 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.direction.Dynamic 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());
}
Aggregations