use of com.xenoage.zong.commands.core.music.MeasureAdd in project Zong by Xenoage.
the class ScoreFactory method create1Staff.
/**
* Creates a score with a single staff and 1 empty measure.
*/
public static Score create1Staff() {
Score score = new Score();
new PartAdd(score, new Part("", null, 1, null), 0, null).execute();
new MeasureAdd(score, 1).execute();
return score;
}
use of com.xenoage.zong.commands.core.music.MeasureAdd in project Zong by Xenoage.
the class ScoreFactory method create1Staff4Measures.
/**
* Creates a score with a single staff and 4 empty measures.
*/
public static Score create1Staff4Measures() {
Score score = create1Staff();
new MeasureAdd(score, 3).execute();
return score;
}
use of com.xenoage.zong.commands.core.music.MeasureAdd in project Zong by Xenoage.
the class DynamicsFinderTest method getAdvancedScore.
/**
* See {@link #testAdvanced()}.
*/
private Score getAdvancedScore() {
Score score = new Score();
Wedge w;
new PartAdd(score, new Part("", null, 2, null), 0, null).execute();
new MeasureAdd(score, 5).execute();
// time signature and repeats
new ColumnElementWrite(new TimeSignature(TimeType.Companion.getTime_4_4()), score.getColumnHeader(0), null, null).execute();
new ColumnElementWrite(Companion.barlineForwardRepeat(Regular), score.getColumnHeader(1), null, MeasureSide.Left).execute();
new ColumnElementWrite(Companion.barlineBackwardRepeat(Regular, 1), score.getColumnHeader(2), null, MeasureSide.Right).execute();
// staff 0
new MeasureElementWrite(new Dynamic(mp), score.getMeasure(atMeasure(0, 0)), Companion.get_0()).execute();
new MeasureElementWrite(new Dynamic(pp), score.getMeasure(atMeasure(0, 2)), Companion.get_0()).execute();
new MeasureElementWrite(new Dynamic(f), score.getMeasure(atMeasure(0, 3)), Companion.get_1$2()).execute();
new MeasureElementWrite(w = new Wedge(Crescendo), score.getMeasure(atMeasure(0, 3)), Companion.get_3$4()).execute();
new MeasureElementWrite(new WedgeEnd(w), score.getMeasure(atMeasure(0, 4)), Companion.get_1$4()).execute();
new MeasureElementWrite(new Dynamic(pp), score.getMeasure(atMeasure(0, 4)), Companion.get_1$2()).execute();
// voice 0
val cursor = new Cursor(score, mp0, true);
cursor.write(new Rest(Companion.get_1()));
cursor.write(new Rest(Companion.get_1()));
cursor.write(new Rest(Companion.get_1()));
cursor.write(new Rest(Companion.get_1()));
// voice 1
cursor.setMp(atElement(0, 0, 1, 0));
cursor.write(new Rest(Companion.get_1$2()));
val chord = chord(Companion.pi(0, 4), Companion.get_1$2());
chord.addDirection(new Dynamic(mf));
cursor.write(chord);
cursor.write(new Rest(Companion.get_1()));
cursor.write(new Rest(Companion.get_1()));
cursor.setMp(atElement(0, 4, 1, 0));
cursor.write(new Rest(Companion.get_1()));
// staff 1
new MeasureElementWrite(new Dynamic(ff), score.getMeasure(atMeasure(1, 0)), Companion.get_0()).execute();
new MeasureElementWrite(w = new Wedge(Diminuendo), score.getMeasure(atMeasure(1, 0)), Companion.get_0()).execute();
new MeasureElementWrite(new WedgeEnd(w), score.getMeasure(atMeasure(1, 2)), Companion.get_0()).execute();
new MeasureElementWrite(new Dynamic(mp), score.getMeasure(atMeasure(1, 2)), Companion.get_0()).execute();
new MeasureElementWrite(new Dynamic(p), score.getMeasure(atMeasure(1, 3)), Companion.get_0()).execute();
return score;
}
use of com.xenoage.zong.commands.core.music.MeasureAdd in project Zong by Xenoage.
the class RepetitionsFinderTest method testSimple.
/**
* Test case with no repeats at all:
*
* measures: | | | ||
* numbers: |0 |1 |2 ||
*/
@Test
public void testSimple() {
score = ScoreFactory.create1Staff();
new MeasureAdd(score, 2).execute();
val expectedRepetitions = new Repetitions(ilist(repetition(0, 3)));
runTest(new TestCase(score, expectedRepetitions));
}
use of com.xenoage.zong.commands.core.music.MeasureAdd in project Zong by Xenoage.
the class RepetitionsFinderTest method testVoltas.
/**
* Test case with voltas, with the following repetitions:
* ___ ___ ___ ____ ___ _____ _____
* voltas: 1 2 1 2 1 2+3 def
* measures: | | :| | | | :| |: | :| :| ||
* numbers: |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |10 ||
*/
@Test
public void testVoltas() {
score = ScoreFactory.create1Staff();
new MeasureAdd(score, 10).execute();
writeVolta(1, 1, range(1, 1));
writeBackwardRepeat(1, 1);
writeVolta(2, 1, range(2, 2));
writeVolta(5, 1, range(1, 1));
writeBackwardRepeat(5, 1);
writeVolta(6, 1, range(2, 2));
writeForwardRepeat(7);
writeVolta(8, 1, range(1, 1));
writeBackwardRepeat(8, 1);
writeVolta(9, 1, range(2, 3));
// should be 2, but 1 is also fine since within a volta we use this repeat sign implicitly
writeBackwardRepeat(9, 1);
writeVolta(10, 1, null);
val expectedRepetitions = new Repetitions(ilist(repetition(0, 2), repetition(0, 1), // -> back to the very beginning (because of missing forward repeat)
repetition(2, 6), repetition(0, 2), repetition(0, 1), repetition(2, 5), repetition(6, 9), repetition(7, 8), repetition(9, 10), repetition(7, 8), repetition(9, 10), repetition(7, 8), repetition(10, 11)));
runTest(new TestCase(score, expectedRepetitions));
}
Aggregations