use of com.xenoage.zong.core.music.direction.Words in project Zong by Xenoage.
the class StrategyTest method getScore.
@Override
public Score getScore() {
// collect test material
List<Example> examples = getAllExamples();
// text style
FormattedTextStyle style = Companion.getDefaultStyle().withFont(new FontInfo("Arial", 6f, FontStyle.normal));
// one chord in each measure
Score score = ScoreFactory.create1Staff();
Cursor cursor = new Cursor(score, mp0, true);
cursor.write(new TimeSignature(TimeType.Companion.getTime_3_4()));
for (int i : range(examples)) {
Example example = examples.get(i);
cursor.setMp(atElement(0, i, 0, 0));
// write key
int fifths = ((TraditionalKey) example.getContext().getKey()).getFifths();
cursor.write((ColumnElement) new TraditionalKey(fifths));
// write example name (each 2nd example one line down for better reading)
String text = (i % 2 == 1 ? "\n" : "") + example.getName();
cursor.write((MeasureElement) new Words(styleText(text, style)));
// write chord with all accidentals from context (or a rest)
Map<Pitch, Integer> accs = example.getContext().getAccidentals();
if (accs.size() > 0) {
Pitch[] pitches = new Pitch[accs.size()];
int accIndex = 0;
for (Pitch acc : accs.keySet()) {
pitches[accIndex] = Companion.pi(acc.getStep(), accs.get(acc), acc.getOctave());
accIndex++;
}
Chord accsChords = ChordFactory.chord(pitches, Companion.get_1$4());
cursor.write(accsChords);
} else {
cursor.write(new Rest(Companion.get_1$4()));
}
// write a rest
cursor.write(new Rest(Companion.get_1$4()));
// write the tested chord
Chord testedChord = ChordFactory.chord(example.getPitches().toArray(new Pitch[0]), Companion.get_1$4());
cursor.write(testedChord);
}
return score;
}
use of com.xenoage.zong.core.music.direction.Words in project Zong by Xenoage.
the class Test32b method testStyle.
@Test
public void testStyle() {
Score score = getScore();
for (int i = 0; i < expectedTexts.size(); ) {
MP mp = expectedTexts.get(i).get1();
List<Direction> directions = score.getMeasure(mp).getDirections().getAll(mp.beat);
assertTrue("" + mp, directions.size() > 0);
for (val direction : directions) {
assertTrue("" + mp, direction instanceof Words);
check((Words) direction, expectedTexts.get(i).get2(), mp);
i++;
}
}
}
use of com.xenoage.zong.core.music.direction.Words 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());
}
use of com.xenoage.zong.core.music.direction.Words in project Zong by Xenoage.
the class Base21d method getExpectedDirections.
default List<Tuple2<MP, ? extends Direction>> getExpectedDirections() {
List<Tuple2<MP, ? extends Direction>> expectedDirections = alist();
Words largo = new Words(new UnformattedText("Largo"));
largo.setPositioning(Placement.Above);
expectedDirections.add(t(mp0, largo));
Dynamic fp = new Dynamic(DynamicValue.fp);
fp.setPositioning(Placement.Below);
expectedDirections.add(t(mp0, fp));
Dynamic p = new Dynamic(DynamicValue.p);
fp.setPositioning(Placement.Below);
expectedDirections.add(t(mp0.withMeasure(1), p));
return expectedDirections;
}
use of com.xenoage.zong.core.music.direction.Words in project Zong by Xenoage.
the class MeasureElementIteratorTest method createTestScore.
/**
* Test score with 4 staves and 4 measures. In staves 1 and 3, the measures 1 and 3 have each
* three words with text "staff x, measure y, element z" on beats 1/4 and 2/4
*/
public static Score createTestScore() {
Score score = new Score();
Cursor cursor = new Cursor(score, MP.mp0, true);
for (int staff : new int[] { 1, 3 }) {
for (int measure : new int[] { 1, 3 }) {
cursor.setMp(atElement(staff, measure, 0, 0));
for (int element : range(2)) {
cursor.write(new Rest(Companion.fr(1, 4)));
cursor.write((MeasureElement) new Words(new UnformattedText("staff " + staff + ", measure " + measure + ", element " + element)));
}
}
}
return score;
}
Aggregations