Search in sources :

Example 56 with Score

use of com.xenoage.zong.core.Score in project Zong by Xenoage.

the class Test45b method test.

@Test
public void test() {
    Score score = getScore();
    assertEqualsEndBarlines(expectedEndBarlines, score);
    assertEqualsVoltas(expectedVoltas, score);
}
Also used : Score(com.xenoage.zong.core.Score) Test(org.junit.Test)

Example 57 with Score

use of com.xenoage.zong.core.Score in project Zong by Xenoage.

the class Test45c method test.

@Test
public void test() {
    Score score = getScore();
    assertEqualsStartBarlines(expectedStartBarlines, score);
    assertEqualsEndBarlines(expectedEndBarlines, score);
}
Also used : Score(com.xenoage.zong.core.Score) Test(org.junit.Test)

Example 58 with Score

use of com.xenoage.zong.core.Score in project Zong by Xenoage.

the class Test45g method test.

@Test
public void test() {
    Score score = getScore();
    assertEqualsStartBarlines(expectedStartBarlines, score);
    assertEqualsEndBarlines(expectedEndBarlines, score);
}
Also used : Score(com.xenoage.zong.core.Score) Test(org.junit.Test)

Example 59 with Score

use of com.xenoage.zong.core.Score in project Zong by Xenoage.

the class Base46e method getExpectedStaff.

static Staff getExpectedStaff() {
    Score score = ScoreFactory.create1Staff();
    Cursor cursor = new Cursor(score, mp0, true);
    cursor.write(new TimeSignature(TimeType.Companion.getTimeCommon()));
    // measure 0, voice 0
    cursor.write(chord(Companion.pi('C', 0, 5), Companion.fr(1, 4)));
    // measure 1, voice 0
    cursor.setMp(atElement(0, 1, 0, 0));
    cursor.write(chord(Companion.pi('C', 0, 5), Companion.fr(1, 4)));
    cursor.write(chord(Companion.pi('A', 0, 4), Companion.fr(1, 4)));
    cursor.write(chord(Companion.pi('F', 0, 4), Companion.fr(1, 4)));
    cursor.write(chord(Companion.pi('C', 0, 5), Companion.fr(1, 4)));
    // measure 1, voice 1
    cursor.setMp(atElement(0, 1, 1, 0));
    cursor.write(new Rest(Companion.fr(1, 4)));
    cursor.write(chord(Companion.pi('C', 0, 4), Companion.fr(1, 4)));
    return score.getStaff(0);
}
Also used : Score(com.xenoage.zong.core.Score) Rest(com.xenoage.zong.core.music.rest.Rest) Cursor(com.xenoage.zong.io.selection.Cursor) TimeSignature(com.xenoage.zong.core.music.time.TimeSignature)

Example 60 with Score

use of com.xenoage.zong.core.Score in project Zong by Xenoage.

the class SystemSpacer method compute.

/**
 * Arranges an optimum number of measures columns in a system, beginning at the given measure,
 * if possible.
 * @param context        the context of the layouter, with the {@link MP} set to the start measure
 * @param usableSizeMm   the usable size within the score frame in mm
 * @param offsetYMm      the vertical offset of the system in mm
 * @param systemIndex    the global system index (over all frames)
 * @param isFirst        true, iff this system is the first one in a score frame
 * @param isAdditional   true, iff this system is created for an additional frame, which is created
 *                       for a complete score layout, but is not part of the defined layout
 * @param measureColumnSpacings  a list of all measure column spacings without leading spacings
 * @param notations      the notations of the elements, needed when a column has to be recomputed
 *                       because of a leading spacing
 */
public Optional<SystemSpacing> compute(Context context, Size2f usableSizeMm, float offsetYMm, int systemIndex, boolean isFirst, boolean isAdditional, List<ColumnSpacing> measureColumnSpacings, Notations notations) {
    int startMeasure = context.mp.measure;
    // test if there is enough height for the system
    Score score = context.score;
    ScoreFormat scoreFormat = score.getFormat();
    ScoreHeader scoreHeader = score.getHeader();
    // compute spacing of staves
    StavesSpacing stavesSpacing = stavesSpacer.compute(score, systemIndex);
    // enough space?
    if (offsetYMm + stavesSpacing.getTotalHeightMm() > usableSizeMm.height) {
        // when the system is the first one in an additional frame, we force it into the frame
        if (false == (isFirst && isAdditional))
            // not enough space
            return absent();
    }
    // compute the usable width for the system
    float systemLeftMarginMm = getLeftMarginMm(systemIndex, scoreFormat, scoreHeader);
    float systemRightMarginMm = getRightMarginMm(systemIndex, scoreFormat, scoreHeader);
    float usableWidthMm = usableSizeMm.width - systemLeftMarginMm - systemRightMarginMm;
    // append system measure-by-measure, until there is no space any more
    // or until there are no measures left
    int measuresCount = score.getMeasuresCount();
    List<ColumnSpacing> system = alist();
    float usedWidthMm = 0;
    int iMeasure;
    while (startMeasure + system.size() < measuresCount) {
        iMeasure = startMeasure + system.size();
        // decide if to add a leading spacing to the current measure or not
        boolean firstMeasure = system.size() == 0;
        ColumnSpacing column;
        if (firstMeasure) {
            // first measure within this system: add leading elements (clef, time sig.)
            column = columnSpacer.compute(context, true, /* leading! */
            notations);
        } else {
            // otherwise: use the precomputed spacing (without leading spacing)
            column = measureColumnSpacings.get(iMeasure);
        }
        // this system is created for a complete score layout
        if (false == canAppend(column, iMeasure, usableWidthMm, usedWidthMm, scoreHeader, firstMeasure)) {
            if (system.size() == 0 && isAdditional) {
                // force the single measure in this system
                usedWidthMm += column.getWidthMm();
                system.add(column);
            } else {
                // no more space for another measure
                break;
            }
        } else {
            usedWidthMm += column.getWidthMm();
            system.add(column);
        }
    }
    // we are finished
    if (system.size() == 0) {
        // not enough space for the system on this area
        return absent();
    } else {
        SystemSpacing ret = new SystemSpacing(system, systemLeftMarginMm, systemRightMarginMm, usedWidthMm, stavesSpacing, offsetYMm);
        return of(ret);
    }
}
Also used : ScoreFormat(com.xenoage.zong.core.format.ScoreFormat) Score(com.xenoage.zong.core.Score) ScoreHeader(com.xenoage.zong.core.header.ScoreHeader) StavesSpacing(com.xenoage.zong.musiclayout.spacing.StavesSpacing) ColumnSpacing(com.xenoage.zong.musiclayout.spacing.ColumnSpacing) SystemSpacing(com.xenoage.zong.musiclayout.spacing.SystemSpacing)

Aggregations

Score (com.xenoage.zong.core.Score)99 Test (org.junit.Test)62 Rest (com.xenoage.zong.core.music.rest.Rest)22 MP (com.xenoage.zong.core.position.MP)19 Voice (com.xenoage.zong.core.music.Voice)15 Cursor (com.xenoage.zong.io.selection.Cursor)15 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)14 Chord (com.xenoage.zong.core.music.chord.Chord)11 StavesList (com.xenoage.zong.core.music.StavesList)9 MusicXmlScoreFileInputTest (com.xenoage.zong.io.musicxml.in.MusicXmlScoreFileInputTest)9 Part (com.xenoage.zong.core.music.Part)8 ColumnHeader (com.xenoage.zong.core.header.ColumnHeader)7 lombok.val (lombok.val)7 TraditionalKey (com.xenoage.zong.core.music.key.TraditionalKey)6 Direction (com.xenoage.zong.core.music.direction.Direction)5 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)5 Size2f (com.xenoage.utils.math.geom.Size2f)4 PartAdd (com.xenoage.zong.commands.core.music.PartAdd)4 ScoreFormat (com.xenoage.zong.core.format.ScoreFormat)4 ScoreHeader (com.xenoage.zong.core.header.ScoreHeader)4