use of com.xenoage.zong.commands.core.music.group.BarlineGroupAdd in project Zong by Xenoage.
the class ScoreRevolutionary method createScore.
public static Score createScore() {
Score score = new Score();
Instrument instr = Instrument.defaultInstrument;
float is = score.getFormat().getInterlineSpace();
StaffLayout staffLayout = new StaffLayout(is * 9);
score.getFormat().setStaffLayoutOther(staffLayout);
ArticulationType[] accent = { ArticulationType.Accent };
ArticulationType[] staccato = { ArticulationType.Staccato };
Fraction f2 = fr(1, 2);
Fraction f4 = fr(1, 4);
Fraction f8 = fr(1, 8);
Fraction f16 = fr(1, 16);
Chord attachC, firstSlurC, lastSlurC;
BezierPoint firstSlurB, lastSlurB;
Part pianoPart = new Part("Piano", null, 2, alist(instr));
new PartAdd(score, pianoPart, 0, null).execute();
// set barlines and brackets
new BarlineGroupAdd(score.getStavesList(), new BarlineGroup(new StavesRange(0, 1), BarlineGroup.Style.Common)).execute();
new BracketGroupAdd(score.getStavesList(), new BracketGroup(new StavesRange(0, 1), BracketGroup.Style.Bracket)).execute();
// use cursor for more convenient input
Cursor cursor = new Cursor(score, MP.mp0, true);
// C minor, C (4/4) time
cursor.write((ColumnElement) new TraditionalKey(-3, Mode.Minor));
cursor.write(new TimeSignature(TimeType.timeCommon));
// first staff: g-clef and some notes
cursor.write(new Clef(ClefType.clefTreble));
// measure 1
// , , FontInfo.defaultValue, );
Tempo tempo = new Tempo(f4, 160);
tempo.setText(ut("Allegro con fuoco."));
tempo.setPositioning(new Position(null, 22f, -5f, -5f));
cursor.write((ColumnElement) tempo);
cursor.write(attachC = chord(f2, accent, pi(B, 4), pi(D, 5), pi(F, 5), pi(G, 5), pi(B, 5)));
attachC.setDirections(addOrNew(attachC.getDirections(), new Dynamic(DynamicValue.f)));
cursor.write(new Rest(f2));
// measure 2
cursor.write(new Rest(f2));
cursor.write(new Rest(f4));
Wedge cresc = new Wedge(WedgeType.Crescendo);
cresc.setPositioning(new Position(null, null, -1f, -2f));
cursor.write((MeasureElement) cresc);
cursor.openBeam();
cursor.write(firstSlurC = chord(fr(3, 16), accent, pi(A, -1, 4), pi(E, -1, 5), pi(F, 5), pi(A, -1, 5)));
cursor.write(lastSlurC = chord(f16, pi(G, 4), pi(G, 5)));
cursor.closeBeam();
cursor.write((MeasureElement) cresc.getWedgeEnd());
firstSlurB = new BezierPoint(sp(is * 0.8f, is * 7.6f), sp(is, is * 0.8f));
lastSlurB = new BezierPoint(sp(0, is * 6f), sp(-is, is));
new SlurAdd(new Slur(SlurType.Slur, clwp(firstSlurC, firstSlurB), clwp(lastSlurC, lastSlurB), null)).execute();
// measure 3
cursor.write(attachC = chord(f2, pi(D, 5), pi(F, 5), pi(G, 5), pi(D, 6)));
new DirectionAdd(new Dynamic(DynamicValue.f), attachC).execute();
cursor.write(new Rest(f2));
// measure 4
cursor.write(new Rest(f2));
cursor.write(new Rest(f4));
cresc = new Wedge(WedgeType.Crescendo);
cresc.setPositioning(new Position(null, null, -1f, -2f));
cursor.write((MeasureElement) cresc);
cursor.openBeam();
cursor.write(firstSlurC = chord(fr(3, 16), accent, pi(A, -1, 4), pi(E, -1, 5), pi(F, 0, 5), pi(A, -1, 5)));
cursor.write(lastSlurC = chord(f16, pi(G, 0, 4), pi(G, 0, 5)));
cursor.closeBeam();
cursor.write((MeasureElement) cresc.getWedgeEnd());
firstSlurB = new BezierPoint(sp(is * 0.8f, is * 7.6f), sp(is, is * 0.8f));
lastSlurB = new BezierPoint(sp(0, is * 6f), sp(-is, is));
new SlurAdd(new Slur(SlurType.Slur, clwp(firstSlurC, firstSlurB), clwp(lastSlurC, lastSlurB), null)).execute();
// measure 5
cursor.write(attachC = chord(f4, staccato, pi(F, 5), pi(G, 5), pi(D, 6), pi(F, 6)));
new DirectionAdd(new Dynamic(DynamicValue.f), attachC).execute();
cursor.write(new Rest(f4));
cursor.write(new Rest(f2));
// second staff: f-clef some notes
cursor = new Cursor(cursor.getScore(), mp(1, 0, 0, _0, 0), true);
cursor.write(new Clef(ClefType.clefBass));
// measure 1
cursor.openBeam();
cursor.write(new Rest(f8));
cursor.write(firstSlurC = chord(f16, pi(A, -1, 4)));
cursor.write(chord(f16, pi(G, 0, 4)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(F, 0, 4)));
cursor.write(chord(f16, pi(D, 0, 4)));
cursor.write(chord(f16, pi(E, -1, 4)));
cursor.write(chord(f16, pi(D, 0, 4)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(B, 0, 3)));
cursor.write(chord(f16, pi(G, 0, 3)));
cursor.write(chord(f16, pi(A, -1, 3)));
cursor.write(chord(f16, pi(G, 0, 3)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(F, 0, 3)));
cursor.write(chord(f16, pi(D, 0, 3)));
cursor.write(chord(f16, pi(E, -1, 3)));
cursor.write(chord(f16, pi(D, 0, 3)));
cursor.closeBeam();
// measure 2
cursor.openBeam();
cursor.write(chord(f16, accent, pi(B, 0, 2)));
cursor.write(chord(f16, pi(G, 0, 2)));
cursor.write(chord(f16, pi(A, -1, 2)));
cursor.write(chord(f16, pi(G, 0, 2)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(F, 0, 2)));
cursor.write(chord(f16, pi(D, 0, 2)));
cursor.write(chord(f16, pi(E, -1, 2)));
cursor.write(chord(f16, pi(D, 0, 2)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(C, 0, 2)));
cursor.write(chord(f16, pi(G, 0, 1)));
cursor.write(chord(f16, pi(C, 0, 2)));
cursor.write(chord(f16, pi(G, 0, 1)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(C, 0, 2)));
cursor.write(chord(f16, pi(G, 0, 1)));
cursor.write(chord(f16, pi(C, 0, 2)));
cursor.write(lastSlurC = chord(f16, pi(G, 0, 1)));
cursor.closeBeam();
firstSlurB = new BezierPoint(sp(0, is * 1.5f), sp(15, 5));
lastSlurB = new BezierPoint(sp(0, is * 7.5f), sp(-is * 5, is * 2));
new SlurAdd(new Slur(SlurType.Slur, clwp(firstSlurC, firstSlurB), clwp(lastSlurC, lastSlurB), null)).execute();
// measure 3
cursor.write(chord(f8, staccato, pi(B, 0, 1)));
cursor.openBeam();
cursor.write(firstSlurC = chord(f16, pi(A, -1, 4)));
cursor.write(chord(f16, pi(G, 0, 4)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(F, 0, 4)));
cursor.write(chord(f16, pi(D, 0, 4)));
cursor.write(chord(f16, pi(E, -1, 4)));
cursor.write(chord(f16, pi(D, 0, 4)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(B, 0, 3)));
cursor.write(chord(f16, pi(G, 0, 3)));
cursor.write(chord(f16, pi(A, -1, 3)));
cursor.write(chord(f16, pi(G, 0, 3)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(F, 0, 3)));
cursor.write(chord(f16, pi(D, 0, 3)));
cursor.write(chord(f16, pi(E, -1, 3)));
cursor.write(lastSlurC = chord(f16, pi(D, 0, 3)));
cursor.closeBeam();
firstSlurB = new BezierPoint(sp(0, is * 1.5f), sp(15, 3));
lastSlurB = new BezierPoint(sp(0, is * 5f), sp(-is * 5.5f, is * 2));
new SlurAdd(new Slur(SlurType.Slur, clwp(firstSlurC, firstSlurB), clwp(lastSlurC, lastSlurB), null)).execute();
// measure 4
cursor.openBeam();
cursor.write(firstSlurC = chord(f16, accent, pi(B, 0, 2)));
cursor.write(chord(f16, pi(G, 0, 2)));
cursor.write(chord(f16, pi(A, -1, 2)));
cursor.write(chord(f16, pi(G, 0, 2)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(F, 0, 2)));
cursor.write(chord(f16, pi(D, 0, 2)));
cursor.write(chord(f16, pi(E, -1, 2)));
cursor.write(chord(f16, pi(D, 0, 2)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(C, 0, 2)));
cursor.write(chord(f16, pi(G, 0, 1)));
cursor.write(chord(f16, pi(C, 0, 2)));
cursor.write(chord(f16, pi(G, 0, 1)));
cursor.closeBeam();
cursor.openBeam();
cursor.write(chord(f16, accent, pi(C, 0, 2)));
cursor.write(chord(f16, pi(G, 0, 1)));
cursor.write(chord(f16, pi(C, 0, 2)));
cursor.write(lastSlurC = chord(f16, pi(G, 0, 1)));
cursor.closeBeam();
firstSlurB = new BezierPoint(sp(-is, is * 8.5f), sp(15, 4));
lastSlurB = new BezierPoint(sp(0, is * 7.5f), sp(-is * 5, is * 2));
new SlurAdd(new Slur(SlurType.Slur, clwp(firstSlurC, firstSlurB), clwp(lastSlurC, lastSlurB), null)).execute();
// measure 5
cursor.write(chord(f4, staccato, pi(B, 0, 1)));
cursor.write(new Rest(f4));
cursor.write(new Rest(f2));
// end line
Barline barlineEnd = Barline.barline(BarlineStyle.LightHeavy);
new ColumnElementWrite(barlineEnd, score.getColumnHeader(4), null, MeasureSide.Right).execute();
return score;
}
Aggregations