Search in sources :

Example 1 with MeasureAdd

use of com.xenoage.zong.commands.core.music.MeasureAdd in project Zong by Xenoage.

the class RepetitionsFinderTest method testMiddleBarlines.

/**
 * Test case with barline repeats, also within measures, with the following repetitions:
 *
 * repeats:                             2x
 * measures:   |     |     /:    :|    :\  |  /:  :\ |
 * numbers:    |0    |1           |2       |3        |
 */
@Test
public void testMiddleBarlines() {
    score = ScoreFactory.create1Staff();
    new MeasureAdd(score, 3).execute();
    writeMiddleForwardRepeat(1, Companion.get_1$2());
    writeBackwardRepeat(1, 1);
    writeMiddleBackwardRepeat(2, Companion.get_1$2(), 2);
    writeMiddleForwardRepeat(3, Companion.get_1$4());
    writeMiddleBackwardRepeat(3, Companion.get_3$4(), 1);
    val expectedRepetitions = new Repetitions(ilist(new Repetition(bp(0, Companion.get_0()), bp(2, Companion.get_0())), new Repetition(bp(1, Companion.get_1$2()), bp(2, Companion.get_1$2())), new Repetition(bp(1, Companion.get_1$2()), bp(2, Companion.get_0())), new Repetition(bp(1, Companion.get_1$2()), bp(2, Companion.get_1$2())), new Repetition(bp(1, Companion.get_1$2()), bp(2, Companion.get_0())), new Repetition(bp(1, Companion.get_1$2()), bp(3, Companion.get_3$4())), new Repetition(bp(3, Companion.get_1$4()), bp(4, Companion.get_0()))));
    runTest(new TestCase(score, expectedRepetitions));
}
Also used : lombok.val(lombok.val) MeasureAdd(com.xenoage.zong.commands.core.music.MeasureAdd) Test(org.junit.Test)

Example 2 with MeasureAdd

use of com.xenoage.zong.commands.core.music.MeasureAdd in project Zong by Xenoage.

the class RepetitionsFinderTest method testSenzaRep.

/**
 * Test case with voltas and repeats, but with a senza repetizione da capo:
 *                   ___ ___             ___ ____
 * voltas:           1   2               1   2  d.c. senza rep
 * measures:   |    |  :|   |:  |  :|:  |  :|   ||
 * numbers:    |0   |1  |2  |3  |4  |5  |6  |7  ||
 */
@Test
public void testSenzaRep() {
    score = ScoreFactory.create1Staff();
    new MeasureAdd(score, 7).execute();
    writeVolta(1, 1, range(1, 1));
    writeBackwardRepeat(1, 1);
    writeVolta(2, 1, range(2, 2));
    writeForwardRepeat(3);
    writeBackwardRepeat(4, 1);
    writeForwardRepeat(5);
    writeVolta(6, 1, range(1, 1));
    writeBackwardRepeat(6, 1);
    writeVolta(7, 1, range(2, 2));
    writeNavigationOrigin(7, new DaCapo(false));
    val expectedRepetitions = new Repetitions(ilist(repetition(0, 2), repetition(0, 1), repetition(2, 5), repetition(3, 7), repetition(5, 6), repetition(7, 8), repetition(0, 1), repetition(2, 6), repetition(7, 8)));
    runTest(new TestCase(score, expectedRepetitions));
}
Also used : lombok.val(lombok.val) MeasureAdd(com.xenoage.zong.commands.core.music.MeasureAdd) Test(org.junit.Test)

Example 3 with MeasureAdd

use of com.xenoage.zong.commands.core.music.MeasureAdd in project Zong by Xenoage.

the class RepetitionsFinderTest method testBarlines.

/**
 * Test case with barline repeats, with the following repetitions:
 *
 * repeats:                 2x
 * measures:   |    :|:    :|     :|
 * numbers:    |0    |1     |2     |
 */
@Test
public void testBarlines() {
    score = ScoreFactory.create1Staff();
    new MeasureAdd(score, 2).execute();
    writeBackwardRepeat(0, 1);
    writeForwardRepeat(1);
    writeBackwardRepeat(1, 2);
    writeBackwardRepeat(2, 1);
    val expectedRepetitions = new Repetitions(ilist(repetition(0, 1), repetition(0, 2), repetition(1, 2), repetition(1, 3), repetition(1, 2), repetition(1, 2), repetition(1, 3)));
    runTest(new TestCase(score, expectedRepetitions));
}
Also used : lombok.val(lombok.val) MeasureAdd(com.xenoage.zong.commands.core.music.MeasureAdd) Test(org.junit.Test)

Example 4 with MeasureAdd

use of com.xenoage.zong.commands.core.music.MeasureAdd in project Zong by Xenoage.

the class RepetitionsFinderTest method testNavigationSigns.

/**
 * Test case with coda/segna/dacapo, with the following repetitions:
 *
 *                                senzarep                                 conrep                        senzarep
 *                (tocoda)        (dacapo)      (coda)      (segno)      (dalsegno)     (segno2)       (dalsegno2)
 * measures:   |    :|          |    |          |       |   |:       :|      |          |        |:        :|      ||
 * numbers:    |0    |1         |2   |3         |4      |5  |6        |7     |8         |9       |10        |11    ||
 */
@Test
public void testNavigationSigns() {
    score = ScoreFactory.create1Staff();
    new MeasureAdd(score, 11).execute();
    writeBackwardRepeat(0, 1);
    writeNavigationOrigin(0, new Coda());
    writeNavigationOrigin(2, new DaCapo(false));
    writeNavigationTarget(4, new Coda());
    writeForwardRepeat(6);
    writeNavigationTarget(6, new Segno());
    writeBackwardRepeat(6, 1);
    writeNavigationOrigin(7, new Segno());
    writeForwardRepeat(10);
    writeNavigationTarget(9, new Segno());
    writeBackwardRepeat(10, 1);
    writeNavigationOrigin(10, segno(false));
    val expectedRepetitions = new Repetitions(ilist(repetition(0, 1), repetition(0, 3), repetition(0, 1), repetition(4, 7), repetition(6, 8), repetition(6, 7), repetition(6, 11), repetition(10, 11), repetition(9, 12)));
    runTest(new TestCase(score, expectedRepetitions));
}
Also used : lombok.val(lombok.val) MeasureAdd(com.xenoage.zong.commands.core.music.MeasureAdd) Test(org.junit.Test)

Example 5 with MeasureAdd

use of com.xenoage.zong.commands.core.music.MeasureAdd in project Zong by Xenoage.

the class TimeMapperTest method getScore.

/**
 * Creates the following score (each space is a quarter note)
 *
 * measures:
 * repetitions: voltas/signs:            1───┐2───┐   d.c. senza rep
 *              barlines:     |    |:   |   :|    |1   ||
 * part 0: staff 0: voice 0:  |1   |1   |2 2 |1   |1   ||
 *                  voice 1:  |    |442 |42 4|1 d |1   ||   //d = direction
 *         staff 1: voice 0:  |2 44|1   |    |1   |1   ||
 * part 1: staff 2: voice 0:  |1   |1   |2 2 |    |2 2 ||
 *
 * play ranges:               0---------------
 *                                 1----     2---------
 *                            3---------     4---------
 */
private Score getScore() {
    val score = new Score();
    new PartAdd(score, new Part("p0", null, 2, null), 0, null).execute();
    new PartAdd(score, new Part("p1", null, 1, null), 1, null).execute();
    new MeasureAdd(score, 5).execute();
    // time, barlines, voltas and signs
    score.getColumnHeader(0).setTime(new TimeSignature(TimeType.Companion.getTime_4_4()));
    score.getColumnHeader(1).setStartBarline(Companion.barlineForwardRepeat(Regular));
    score.getColumnHeader(2).setVolta(new Volta(1, range(1, 1), "1", true));
    score.getColumnHeader(2).setEndBarline(Companion.barlineBackwardRepeat(Regular, 1));
    score.getColumnHeader(3).setVolta(new Volta(1, range(2, 2), "2", true));
    score.getColumnHeader(4).setNavigationOrigin(new DaCapo(false));
    // staff 0, voice 0
    val cursor = new Cursor(score, mp0, true);
    cursor.write(e(1));
    cursor.write(e(1));
    cursor.write(e(2));
    cursor.write(e(2));
    cursor.write(e(1));
    cursor.write(e(1));
    // staff 0, voice 1
    cursor.setMp(atElement(0, 1, 1, 0));
    cursor.write(e(4));
    cursor.write(e(4));
    cursor.write(e(2));
    cursor.write(e(4));
    cursor.write(e(2));
    cursor.write(e(4));
    cursor.write(e(1));
    cursor.write(e(1));
    new MeasureElementWrite(new Dynamic(DynamicValue.f), score.getMeasure(atMeasure(0, 3)), Companion.get_1$2()).execute();
    // staff 1, voice 0
    cursor.setMp(atElement(1, 0, 0, 0));
    cursor.write(e(2));
    cursor.write(e(4));
    cursor.write(e(4));
    cursor.write(e(1));
    cursor.setMp(atElement(1, 2, 0, 0));
    cursor.write(e(1));
    cursor.write(e(1));
    // staff 2, voice 0
    cursor.setMp(atElement(2, 0, 0, 0));
    cursor.write(e(1));
    cursor.write(e(1));
    cursor.write(e(2));
    cursor.write(e(2));
    cursor.setMp(atElement(2, 4, 0, 0));
    cursor.write(e(2));
    cursor.write(e(2));
    return score;
}
Also used : lombok.val(lombok.val) Score(com.xenoage.zong.core.Score) MeasureAdd(com.xenoage.zong.commands.core.music.MeasureAdd) Dynamic(com.xenoage.zong.core.music.direction.Dynamic) Part(com.xenoage.zong.core.music.Part) PartAdd(com.xenoage.zong.commands.core.music.PartAdd) DaCapo(com.xenoage.zong.core.music.direction.DaCapo) Cursor(com.xenoage.zong.io.selection.Cursor) MeasureElementWrite(com.xenoage.zong.commands.core.music.MeasureElementWrite) TimeSignature(com.xenoage.zong.core.music.time.TimeSignature) Volta(com.xenoage.zong.core.music.volta.Volta)

Aggregations

MeasureAdd (com.xenoage.zong.commands.core.music.MeasureAdd)13 lombok.val (lombok.val)11 Test (org.junit.Test)8 PartAdd (com.xenoage.zong.commands.core.music.PartAdd)3 Score (com.xenoage.zong.core.Score)3 Part (com.xenoage.zong.core.music.Part)3 MeasureElementWrite (com.xenoage.zong.commands.core.music.MeasureElementWrite)2 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)2 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)2 Volta (com.xenoage.zong.core.music.volta.Volta)2 Cursor (com.xenoage.zong.io.selection.Cursor)2 ColumnElementWrite (com.xenoage.zong.commands.core.music.ColumnElementWrite)1 DaCapo (com.xenoage.zong.core.music.direction.DaCapo)1 Wedge (com.xenoage.zong.core.music.direction.Wedge)1 WedgeEnd (com.xenoage.zong.core.music.direction.WedgeEnd)1 Rest (com.xenoage.zong.core.music.rest.Rest)1