use of com.xenoage.zong.core.Score in project Zong by Xenoage.
the class VoicesBeatOffsetterTest method createTestScore3Voices.
private Score createTestScore3Voices() {
Score score = new Score();
score.getFormat().setInterlineSpace(10);
Cursor cursor = new Cursor(score, mp0, true);
cursor.write(new TimeSignature(Companion.getTime_4_4()));
// 2: half note, 4: quarter note, 8: eighth note, 3: quarter triplet
// voice 1: | 4 4 4 4 | (staff 1)
// voice 2: | 8 8 8 8 2 | (staff 1)
// voice 3: | 3 3 3 8 8 4 | (staff 2)
// voice 1 (staff 1)
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 4)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 4)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 4)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 4)));
// voice 2 (staff 1)
cursor.setMp(atElement(0, 0, 1, 0));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 2)));
// voice 3 (staff 2)
cursor.setMp(atElement(1, 0, 0, 0));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 6)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 6)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 6)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 4)));
return score;
}
use of com.xenoage.zong.core.Score in project Zong by Xenoage.
the class VoicesBeatOffsetterTest method createTestScore1Voice.
private Score createTestScore1Voice() {
Score score = new Score();
score.getFormat().setInterlineSpace(1);
Cursor cursor = new Cursor(score, mp0, true);
cursor.write(new Clef(ClefType.Companion.getClefTreble()));
cursor.write((MeasureElement) new TraditionalKey(-3));
cursor.write(new TimeSignature(TimeType.Companion.timeType(6, 4)));
// beats: 0, 2, 3, 4, 8.
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 4)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 2)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 2)));
return score;
}
use of com.xenoage.zong.core.Score in project Zong by Xenoage.
the class Base42a method getExpectedStaff.
/**
* Gets the expected musical data, but without the dynamics, fermatas, articulations and slurs.
*/
static Staff getExpectedStaff() {
Score score = ScoreFactory.create1Staff();
Cursor cursor = new Cursor(score, mp0, true);
cursor.write(new TimeSignature(TimeType.Companion.getTime_4_4()));
// measure 0, voice 0
cursor.write(addLyric(chord(Companion.pi('E', 0, 5), Companion.fr(1, 2)), "This"));
cursor.write(addLyric(chord(Companion.pi('D', 0, 5), Companion.fr(1, 4)), "is"));
cursor.write(addLyric(chord(Companion.pi('B', 0, 4), Companion.fr(1, 4)), "the"));
// measure 1, voice 0
cursor.write(new Rest(Companion.fr(1, 4)));
cursor.write(addLyric(chord(Companion.pi('D', 0, 5), Companion.fr(1, 4)), "lyrics"));
cursor.write(addLyric(chord(Companion.pi('B', 0, 3), Companion.fr(3, 8)), "of"));
cursor.write(addLyric(chord(Companion.pi('C', 0, 5), Companion.fr(1, 8)), "Voice1"));
// measure 0, voice 1
cursor.setMp(atElement(0, 0, 1, 0));
cursor.write(addLyric(chord(Companion.pi('C', 0, 5), Companion.fr(1, 2)), "This"));
cursor.write(addLyric(chord(Companion.pi('B', 0, 4), Companion.fr(1, 4)), "is"));
cursor.write(addLyric(chord(Companion.pi('G', 0, 4), Companion.fr(1, 4)), "the"));
// measure 1, voice 1
cursor.write(new Rest(Companion.fr(1, 4)));
cursor.write(addLyric(chord(Companion.pi('B', 0, 4), Companion.fr(1, 4)), "lyrics"));
cursor.write(addLyric(chord(Companion.pi('G', 0, 3), Companion.fr(3, 8)), "of"));
cursor.write(addLyric(chord(Companion.pi('A', 0, 4), Companion.fr(1, 8)), "Voice2"));
return score.getStaff(0);
}
use of com.xenoage.zong.core.Score in project Zong by Xenoage.
the class Base42b method getExpectedStaves.
/**
* Gets the expected musical data, but without the dynamics, articulations and slurs
* and also without the clef changes.
*/
static Staff[] getExpectedStaves() {
Score score = ScoreFactory.create1Staff();
Cursor cursor = new Cursor(score, mp0, true);
cursor.write(new TimeSignature(TimeType.Companion.getTime_6_8()));
// staff 1, measure 0
cursor.write(chord(Companion.pi('F', 0, 4), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('D', 0, 4), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('B', 0, 3), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 3), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('F', 0, 3), Companion.fr(1, 4)));
// staff 1, measure 1
cursor.write(chord(Companion.pi('E', 0, 5), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('C', 0, 5), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 4), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 4), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('F', 0, 4), Companion.fr(1, 4)));
// staff 1, measure 0
cursor.setMp(atElement(1, 0, 0, 0));
cursor.write(new Rest(Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi('A', 0, 2), Companion.fr(1, 16)));
cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 16)));
cursor.write(chord(Companion.pi('F', 1, 2), Companion.fr(1, 16)));
cursor.write(chord(Companion.pi('G', 0, 2), Companion.fr(1, 16)));
// staff 1, measure 1
cursor.write(chord(new Pitch[] { Companion.pi('C', 0, 3), Companion.pi('E', 0, 3), Companion.pi('G', 0, 3), Companion.pi('C', 0, 4) }, Companion.fr(1, 4)));
cursor.write(new Rest(Companion.fr(1, 8)));
cursor.write(new Rest(Companion.fr(1, 4)));
cursor.write(chord(Companion.pi('G', 0, 3), Companion.fr(1, 8)));
return new Staff[] { score.getStaff(0), score.getStaff(1) };
}
use of com.xenoage.zong.core.Score in project Zong by Xenoage.
the class ScoreDocScoreView method updateScreen.
@Override
public void updateScreen(Size2i screenSizePx, float zoom) {
this.screenSizePx = screenSizePx;
this.zoom = zoom;
// recompute the layout, so that each page fits into the available screen space
Size2f pageSizeMm = pxToMm(screenSizePx, zoom);
float marginMm = pxToMm(marginPx, zoom);
PageFormat pageFormat = new PageFormat(pageSizeMm, new PageMargins(marginMm, marginMm, marginMm, marginMm));
Size2f frameSizeMm = new Size2f(pageFormat.getUseableWidth(), pageFormat.getUseableHeight());
// first page needs space for title text
titleTextHeightPx = screenSizePx.height / 20f;
float firstFrameOffsetY = pxToMm(titleTextHeightPx, zoom);
Size2f firstFrameSizeMm = new Size2f(frameSizeMm.width, frameSizeMm.height - firstFrameOffsetY);
// delete unnecessary layout information, like system distances or system breaks
Score score = doc.getScore();
score.setFormat(new ScoreFormat());
ScoreHeader header = score.getHeader();
for (int i : range(header.getSystemLayouts())) {
SystemLayout sl = header.getSystemLayout(i);
if (sl != null)
sl.setDistance(SystemLayout.defaultDistance);
}
for (int i : range(header.getColumnHeaders())) {
ColumnHeader ch = header.getColumnHeader(i);
if (ch.getMeasureBreak() != null)
ch.setBreak(null);
}
// layout the score to find out the needed space
Context context = new Context(score, App.getSymbolPool(), doc.getLayout().getDefaults().getLayoutSettings());
Target target = new Target(alist(new ScoreLayoutArea(firstFrameSizeMm)), new ScoreLayoutArea(frameSizeMm), true);
ScoreLayouter layouter = new ScoreLayouter(context, target);
ScoreLayout scoreLayout = layouter.createScoreLayout();
// create and fill at least one page
Layout layout = new Layout(doc.getLayout().getDefaults());
ScoreFrameChain chain = null;
for (int i = 0; i < scoreLayout.frames.size(); i++) {
Page page = new Page(pageFormat);
Point2f position;
Size2f size;
if (i == 0) {
// first page
position = new Point2f(pageSizeMm.width / 2, pageSizeMm.height / 2 + firstFrameOffsetY);
size = firstFrameSizeMm;
} else {
// other pages
position = new Point2f(pageSizeMm.width / 2, pageSizeMm.height / 2);
size = frameSizeMm;
}
ScoreFrame frame = new ScoreFrame();
frame.setPosition(position);
frame.setSize(size);
page.addFrame(frame);
layout.addPage(page);
if (chain == null) {
chain = new ScoreFrameChain(score);
chain.setScoreLayout(scoreLayout);
}
chain.add(frame);
}
this.layout = layout;
}
Aggregations