use of material.accidentals.Example 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 material.accidentals.Example in project Zong by Xenoage.
the class StrategyTest method testStrategies.
@Test
public void testStrategies() {
// collect test material
List<Example> examples = getAllExamples();
// run tests
List<ExampleResult> failedExamples = alist();
for (Example example : examples) {
ExampleResult result = testExample(example);
if (result.getResult() == Result.Failed)
failedExamples.add(result);
}
// list failed examples
if (failedExamples.size() > 0) {
for (ExampleResult example : failedExamples) System.out.println(example.getExample().getName() + " failed: " + example.getComment());
fail(failedExamples.size() + " of " + examples.size() + " examples failed. " + "See console for details.");
}
}
Aggregations