Search in sources :

Example 6 with ColumnHeader

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;
}
Also used : Score(com.xenoage.zong.core.Score) ColumnHeader(com.xenoage.zong.core.header.ColumnHeader) Cursor(com.xenoage.zong.io.selection.Cursor) TimeSignature(com.xenoage.zong.core.music.time.TimeSignature)

Example 7 with ColumnHeader

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());
        }
    }
}
Also used : Score(com.xenoage.zong.core.Score) ColumnHeader(com.xenoage.zong.core.header.ColumnHeader) MP(com.xenoage.zong.core.position.MP) TraditionalKey(com.xenoage.zong.core.music.key.TraditionalKey) Test(org.junit.Test)

Example 8 with ColumnHeader

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()));
}
Also used : Score(com.xenoage.zong.core.Score) ColumnHeader(com.xenoage.zong.core.header.ColumnHeader) MusicContext(com.xenoage.zong.core.music.MusicContext) Test(org.junit.Test)

Example 9 with ColumnHeader

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);
}
Also used : ColumnHeader(com.xenoage.zong.core.header.ColumnHeader) Measure(com.xenoage.zong.core.music.Measure)

Example 10 with ColumnHeader

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));
}
Also used : ColumnHeader(com.xenoage.zong.core.header.ColumnHeader) BeatOffset(com.xenoage.zong.musiclayout.spacing.BeatOffset) Test(org.junit.Test)

Aggregations

ColumnHeader (com.xenoage.zong.core.header.ColumnHeader)13 Score (com.xenoage.zong.core.Score)7 Test (org.junit.Test)6 Barline (com.xenoage.zong.core.music.barline.Barline)3 CommandPerformer (com.xenoage.utils.document.command.CommandPerformer)2 Measure (com.xenoage.zong.core.music.Measure)2 TraditionalKey (com.xenoage.zong.core.music.key.TraditionalKey)2 MP (com.xenoage.zong.core.position.MP)2 BeatOffset (com.xenoage.zong.musiclayout.spacing.BeatOffset)2 Paint (android.graphics.Paint)1 Fraction (com.xenoage.utils.math.Fraction)1 Point2f (com.xenoage.utils.math.geom.Point2f)1 Size2f (com.xenoage.utils.math.geom.Size2f)1 MeasureNumbering (com.xenoage.zong.core.format.MeasureNumbering)1 PageFormat (com.xenoage.zong.core.format.PageFormat)1 PageMargins (com.xenoage.zong.core.format.PageMargins)1 ScoreFormat (com.xenoage.zong.core.format.ScoreFormat)1 SystemLayout (com.xenoage.zong.core.format.SystemLayout)1 ScoreHeader (com.xenoage.zong.core.header.ScoreHeader)1 MusicContext (com.xenoage.zong.core.music.MusicContext)1