use of com.xenoage.zong.core.header.ColumnHeader in project Zong by Xenoage.
the class ColumnElementIteratorTest method createTestScore.
/**
* Test score with 4 measures. The measures 1 and 3 have each
* a time signature, a middle barline at 1/4 and an end barline.
*/
public static Score createTestScore() {
Score score = new Score();
Cursor cursor = new Cursor(score, MP.mp0, true);
for (int measure : new int[] { 1, 3 }) {
cursor.setMp(mp(unknown, measure, 0, Companion.get_0(), 0));
cursor.write(new TimeSignature(Companion.getTime_4_4()));
cursor.setMp(mp(unknown, measure, unknown, Companion.fr(1, 4), 0));
cursor.write(Companion.barlineRegular());
ColumnHeader column = score.getColumnHeader(measure);
column.setEndBarline(Companion.barline(LightLight));
}
return score;
}
use of com.xenoage.zong.core.header.ColumnHeader in project Zong by Xenoage.
the class Test13b method test.
@Test
public void test() {
Score score = getScore();
TraditionalKey[] expectedKeys = getExpectedKeys();
MP mp = mp0;
for (int iKey : range(expectedKeys)) {
ColumnHeader column = score.getColumnHeader(mp.measure);
TraditionalKey key = (TraditionalKey) column.getKeys().get(mp.beat);
assertNotNull("mp " + mp, key);
assertEquals("mp " + mp, expectedKeys[iKey].getFifths(), key.getFifths());
assertEquals("mp " + mp, expectedKeys[iKey].getMode(), key.getMode());
mp = mp.withBeat(mp.beat.add(Companion.fr(1, 4)));
if (mp.beat.compareTo(Companion.get_1()) >= 0) {
mp = mp.withMeasure(mp.measure + 1).withBeat(Companion.get_0());
}
}
}
use of com.xenoage.zong.core.header.ColumnHeader in project Zong by Xenoage.
the class Test12b method test.
@Test
public void test() {
Score score = getScore();
// musical context must be 4/4, C clef and no accidentals
MusicContext context = score.getMusicContext(mp0, Interval.At, Interval.At);
assertEquals(Companion.fr(4, 4), score.getMeasureBeats(0));
assertEquals(ClefType.Companion.getClefTreble(), context.getClef());
for (int i = 0; i < 7; i++) assertEquals(0, context.getKey().getAlterations()[i]);
// there should be a C clef in the first measure
assertEquals(ClefType.Companion.getClefTreble(), score.getMeasure(mp0).getClefs().get(Companion.get_0()).getType());
// there should be a time signature and key signature in the measure column
ColumnHeader header = score.getHeader().getColumnHeader(0);
assertEquals(TimeType.Companion.getTime_4_4(), header.getTime().getType());
assertNotNull(header.getKeys().get(Companion.get_0()));
}
use of com.xenoage.zong.core.header.ColumnHeader in project Zong by Xenoage.
the class MeasureElementsSpacer method compute.
public List<ElementSpacing> compute(Context context, boolean existsLeadingSpacing, List<VoiceSpacing> voiceSpacings, Notations notations) {
Measure measure = context.score.getMeasure(context.mp);
ColumnHeader columnHeader = context.score.getHeader().getColumnHeader(context.mp.measure);
return compute(measure.getClefs(), columnHeader.getKeys(), columnHeader.getTime(), existsLeadingSpacing, voiceSpacings, context.mp.staff, notations, context.settings);
}
use of com.xenoage.zong.core.header.ColumnHeader in project Zong by Xenoage.
the class BarlinesBeatOffsetterTest method computeBeatOffsetsTest.
@Test
public void computeBeatOffsetsTest() {
// notes: | 1/4 1/4 || 1/4 | 1/4 |
// barlines: |: :||: | :|
// original distance between notes
float d = 2;
// interline space
float is = 1.5f;
// create original offsets
List<BeatOffset> baseOffsets = alist(new BeatOffset(Companion.fr(0, 4), 0 * d), new BeatOffset(Companion.fr(1, 4), 1 * d), new BeatOffset(Companion.fr(2, 4), 2 * d), new BeatOffset(Companion.fr(3, 4), 3 * d), new BeatOffset(Companion.fr(4, 4), 4 * d));
// create barlines
ColumnHeader ch = new ColumnHeader(null, 0);
ch.setStartBarline(Companion.barlineForwardRepeat(HeavyLight));
ch.setMiddleBarline(Companion.barlineMiddleBothRepeat(LightLight, 1), Companion.fr(2, 4));
ch.setMiddleBarline(Companion.barlineRegular(), Companion.fr(3, 4));
ch.setEndBarline(Companion.barlineBackwardRepeat(LightHeavy, 1));
// compute new offsets and check results
BarlinesBeatOffsetter.Result result = testee.compute(baseOffsets, ch, is);
float dRep = BarlinesBeatOffsetter.repeatSpace * is;
float dMid = BarlinesBeatOffsetter.midBarlineSpace * is;
// note offsets
List<BeatOffset> vo = result.voiceElementOffsets;
assertEquals(5, vo.size());
assertEquals(new BeatOffset(Companion.fr(0, 4), 0 * d + 1 * dRep), vo.get(0));
assertEquals(new BeatOffset(Companion.fr(1, 4), 1 * d + 1 * dRep), vo.get(1));
assertEquals(new BeatOffset(Companion.fr(2, 4), 2 * d + 3 * dRep + 1 * dMid), vo.get(2));
assertEquals(new BeatOffset(Companion.fr(3, 4), 3 * d + 3 * dRep + 2 * dMid), vo.get(3));
assertEquals(new BeatOffset(Companion.fr(4, 4), 4 * d + 3 * dRep + 2 * dMid), vo.get(4));
// barline offsets
List<BeatOffset> bo = result.barlineOffsets;
assertEquals(4, bo.size());
assertEquals(new BeatOffset(Companion.fr(0, 4), 0 * d + 0 * dRep), bo.get(0));
assertEquals(new BeatOffset(Companion.fr(2, 4), 2 * d + 2 * dRep), bo.get(1));
assertEquals(new BeatOffset(Companion.fr(3, 4), 3 * d + 3 * dRep + 1 * dMid), bo.get(2));
assertEquals(new BeatOffset(Companion.fr(4, 4), 4 * d + 4 * dRep + 2 * dMid), bo.get(3));
}
Aggregations