Search in sources :

Example 16 with Part

use of com.xenoage.zong.core.music.Part 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;
}
Also used : lombok.val(lombok.val) Dynamic(com.xenoage.zong.core.music.direction.Dynamic) ColumnElementWrite(com.xenoage.zong.commands.core.music.ColumnElementWrite) Cursor(com.xenoage.zong.io.selection.Cursor) Wedge(com.xenoage.zong.core.music.direction.Wedge) TimeSignature(com.xenoage.zong.core.music.time.TimeSignature) Score(com.xenoage.zong.core.Score) MeasureAdd(com.xenoage.zong.commands.core.music.MeasureAdd) Rest(com.xenoage.zong.core.music.rest.Rest) Part(com.xenoage.zong.core.music.Part) PartAdd(com.xenoage.zong.commands.core.music.PartAdd) MeasureElementWrite(com.xenoage.zong.commands.core.music.MeasureElementWrite) WedgeEnd(com.xenoage.zong.core.music.direction.WedgeEnd)

Example 17 with Part

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

the class Test41a method test.

@Test
public void test() {
    Score score = getScore();
    StavesList stavesList = score.getStavesList();
    List<Part> parts = stavesList.getParts();
    assertEquals(expectedNames.length, parts.size());
    for (int i : range(parts)) {
        assertEquals(expectedNames[i], parts.get(i).getName());
        int firstStaffIndex = stavesList.getPartStaffIndices(parts.get(i)).getStart();
        assertEquals(expectedPitches[i], getFirstPitch(score, firstStaffIndex));
    }
}
Also used : Score(com.xenoage.zong.core.Score) Part(com.xenoage.zong.core.music.Part) StavesList(com.xenoage.zong.core.music.StavesList) Test(org.junit.Test)

Example 18 with Part

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

the class Test72c method testTransposes.

@Test
public void testTransposes() {
    // start instrument
    Part part = score.getStavesList().getParts().get(0);
    PitchedInstrument instrument = (PitchedInstrument) part.getFirstInstrument();
    assertEquals(expectedTransposes[0], instrument.getTranspose());
    // instrument change in measure 1
    InstrumentChange instrChange = score.getMeasure(MP.atMeasure(0, 1)).getInstrumentChanges().get(Companion.get_0());
    instrument = (PitchedInstrument) instrChange.getInstrument();
    assertEquals(expectedTransposes[1], instrument.getTranspose());
}
Also used : InstrumentChange(com.xenoage.zong.core.music.InstrumentChange) Part(com.xenoage.zong.core.music.Part) PitchedInstrument(com.xenoage.zong.core.instrument.PitchedInstrument) Test(org.junit.Test)

Example 19 with Part

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

the class Test72a method testTransposes.

@Test
public void testTransposes() {
    for (int iPart : range(3)) {
        Part part = score.getStavesList().getParts().get(iPart);
        PitchedInstrument instrument = (PitchedInstrument) part.getFirstInstrument();
        assertEquals("Part " + iPart, expectedTransposes[iPart], instrument.getTranspose());
    }
}
Also used : Part(com.xenoage.zong.core.music.Part) PitchedInstrument(com.xenoage.zong.core.instrument.PitchedInstrument) Test(org.junit.Test)

Aggregations

Part (com.xenoage.zong.core.music.Part)19 Score (com.xenoage.zong.core.Score)8 PitchedInstrument (com.xenoage.zong.core.instrument.PitchedInstrument)6 Test (org.junit.Test)6 PartAdd (com.xenoage.zong.commands.core.music.PartAdd)5 StavesList (com.xenoage.zong.core.music.StavesList)4 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)4 MeasureAdd (com.xenoage.zong.commands.core.music.MeasureAdd)3 MeasureElementWrite (com.xenoage.zong.commands.core.music.MeasureElementWrite)3 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)3 StavesRange (com.xenoage.zong.core.music.group.StavesRange)3 Cursor (com.xenoage.zong.io.selection.Cursor)3 MxlPart (com.xenoage.zong.musicxml.types.partwise.MxlPart)3 lombok.val (lombok.val)3 Fraction (com.xenoage.utils.math.Fraction)2 ColumnElementWrite (com.xenoage.zong.commands.core.music.ColumnElementWrite)2 Instrument (com.xenoage.zong.core.instrument.Instrument)2 Measure (com.xenoage.zong.core.music.Measure)2 Staff (com.xenoage.zong.core.music.Staff)2 Clef (com.xenoage.zong.core.music.clef.Clef)2