Search in sources :

Example 1 with PartAdd

use of com.xenoage.zong.commands.core.music.PartAdd 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)

Example 2 with PartAdd

use of com.xenoage.zong.commands.core.music.PartAdd 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;
}
Also used : MeasureAdd(com.xenoage.zong.commands.core.music.MeasureAdd) Part(com.xenoage.zong.core.music.Part) PartAdd(com.xenoage.zong.commands.core.music.PartAdd)

Example 3 with PartAdd

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

the class MidiVelocityConverterTry method createTestScore.

public static Score createTestScore() {
    Score ret = new Score();
    Instrument instr = Instrument.Companion.getDefaultInstrument();
    Part pianoPart = new Part("Test", "T", 1, ilist(instr));
    new PartAdd(ret, pianoPart, 0, null).execute();
    Cursor cursor = new Cursor(ret, mp0, true);
    cursor.write((ColumnElement) new TraditionalKey(-3));
    cursor.write((ColumnElement) new TimeSignature(Companion.timeType(3, 4)));
    cursor.write(new Clef(ClefType.Companion.getClefTreble()));
    Fraction f4 = Companion.fr(1, 4);
    Chord attachC;
    cursor.write(attachC = chord(f4, Pitch.Companion.pi(Pitch.Companion.getG(), 4)));
    attachC.addDirection(new Dynamic(DynamicValue.pp));
    cursor.write(attachC = chord(f4, Pitch.Companion.pi(Pitch.Companion.getA(), 4)));
    attachC.addDirection(new Dynamic(DynamicValue.ff));
    cursor.write(attachC = chord(f4, Pitch.Companion.pi(Pitch.Companion.getG(), 4)));
    attachC.addDirection(new Dynamic(DynamicValue.sfp));
    /*
		Chord chord;
		Voice voice = measure.getVoices().get(0);
		chord = voice.addNote(pi'G', 0, 4), fr(1, 4));
		chord.addDirection(new Dynamic(DynamicsType.pp));
		
		

		chord = voice.addNote(pi'A', 0, 4), fr(1, 4));
		chord.addDirection(new Dynamic(DynamicsType.ff));

		chord = voice.addNote(pi'G', 0, 4), fr(1, 4));
		chord.addDirection(new Dynamic(DynamicsType.sfp));
		*/
    cursor.setMp(mp0.withVoice(1));
    cursor.write(attachC = chord(f4, Pitch.Companion.pi(Pitch.Companion.getC(), 4)));
    attachC.addDirection(new Dynamic(DynamicValue.fff));
    /*
		voice = measure.addVoice();
		
		chord = voice.addNote(pi'C', 0, 4), fr(1, 4));
		chord.addDirection(new Dynamic(DynamicsType.fff));
		*/
    cursor.setMp(mp0.withMeasure(1));
    cursor.write(attachC = chord(f4, Pitch.Companion.pi(Pitch.Companion.getG(), 4)));
    // cursor.withScore(ScoreController.attachElement(cursor.getScore(), attachC, new Dynamic(DynamicsType.pp)));
    cursor.write(attachC = chord(f4, Pitch.Companion.pi(Pitch.Companion.getA(), 4)));
    attachC.addDirection(new Dynamic(DynamicValue.pp));
    cursor.write(attachC = chord(f4, Pitch.Companion.pi(Pitch.Companion.getG(), 4)));
    attachC.addDirection(new Dynamic(DynamicValue.pp));
    cursor.setMp(cursor.getMP().withElement(0).withVoice(1));
    cursor.write(attachC = chord(f4, Pitch.Companion.pi(Pitch.Companion.getC(), 5)));
    /*		
		measure = staff.getMeasures().get(1);

		voice = measure.getVoices().get(0);
		chord = voice.addNote(pi'G', 0, 4), fr(1, 4));
		//chord.addDirection(new Dynamic(DynamicsType.pp));

		chord = voice.addNote(pi'A', 0, 4), fr(1, 4));
		chord.addDirection(new Dynamic(DynamicsType.pp));

		chord = voice.addNote(pi'G', 0, 4), fr(1, 4));
		chord.addDirection(new Dynamic(DynamicsType.pp));

		voice = measure.addVoice();
		chord = voice.addNote(pi'C', 0, 5), fr(1, 4));
		*/
    cursor.setMp(mp0.withMeasure(2));
    cursor.write(attachC = chord(f4, Pitch.Companion.pi(Pitch.Companion.getG(), 4)));
    attachC.addDirection(new Dynamic(DynamicValue.sfz));
    cursor.write(chord(f4, Pitch.Companion.pi(Pitch.Companion.getA(), 4)));
    // cursor = cursor.withScore(ScoreController.attachElement(cursor.getScore(), attachC, new Dynamic(DynamicsType.pp)));
    cursor.write(chord(f4, Pitch.Companion.pi(Pitch.Companion.getG(), 4)));
    // cursor = cursor.withScore(ScoreController.attachElement(cursor.getScore(), attachC, new Dynamic(DynamicsType.pp)));
    cursor.setMp(mp0.withMeasure(2).withVoice(2));
    cursor.write(chord(f4, Pitch.Companion.pi(Pitch.Companion.getC(), 5)));
    /*
		measure = staff.getMeasures().get(2);

		
		voice = measure.getVoices().get(0);
		chord = voice.addNote(pi'G', 0, 4), fr(1, 4));
		chord.addDirection(new Dynamic(DynamicsType.sfz));

		chord = voice.addNote(pi'A', 0, 4), fr(1, 4));
		//chord.addDirection(new Dynamic(DynamicsType.pp));

		chord = voice.addNote(pi'G', 0, 4), fr(1, 4));
		//chord.addDirection(new Dynamic(DynamicsType.pp));
		
		voice = measure.addVoice();
		voice = measure.addVoice();
		chord = voice.addNote(pi'C',0,5), fr(1,2));

		*/
    return cursor.getScore();
}
Also used : Score(com.xenoage.zong.core.Score) Dynamic(com.xenoage.zong.core.music.direction.Dynamic) Part(com.xenoage.zong.core.music.Part) Instrument(com.xenoage.zong.core.instrument.Instrument) PartAdd(com.xenoage.zong.commands.core.music.PartAdd) Clef(com.xenoage.zong.core.music.clef.Clef) Fraction(com.xenoage.utils.math.Fraction) TraditionalKey(com.xenoage.zong.core.music.key.TraditionalKey) Cursor(com.xenoage.zong.io.selection.Cursor) Chord(com.xenoage.zong.core.music.chord.Chord) TimeSignature(com.xenoage.zong.core.music.time.TimeSignature)

Example 4 with PartAdd

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

the class ChannelMapperTest method createScore.

private Score createScore(int[] midiPrograms, int... partStavesCount) {
    val score = new Score();
    for (int iPart : range(partStavesCount)) {
        Instrument instrument;
        if (midiPrograms[iPart] == drums)
            instrument = new UnpitchedInstrument("part " + iPart);
        else
            instrument = new PitchedInstrument("part " + iPart, midiPrograms[iPart]);
        new PartAdd(score, new Part("", null, partStavesCount[iPart], alist(instrument)), iPart, null).execute();
    }
    return score;
}
Also used : lombok.val(lombok.val) UnpitchedInstrument(com.xenoage.zong.core.instrument.UnpitchedInstrument) Score(com.xenoage.zong.core.Score) PitchedInstrument(com.xenoage.zong.core.instrument.PitchedInstrument) Part(com.xenoage.zong.core.music.Part) UnpitchedInstrument(com.xenoage.zong.core.instrument.UnpitchedInstrument) PitchedInstrument(com.xenoage.zong.core.instrument.PitchedInstrument) Instrument(com.xenoage.zong.core.instrument.Instrument) PartAdd(com.xenoage.zong.commands.core.music.PartAdd)

Example 5 with PartAdd

use of com.xenoage.zong.commands.core.music.PartAdd 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)

Aggregations

PartAdd (com.xenoage.zong.commands.core.music.PartAdd)5 Part (com.xenoage.zong.core.music.Part)5 Score (com.xenoage.zong.core.Score)4 MeasureAdd (com.xenoage.zong.commands.core.music.MeasureAdd)3 Dynamic (com.xenoage.zong.core.music.direction.Dynamic)3 TimeSignature (com.xenoage.zong.core.music.time.TimeSignature)3 Cursor (com.xenoage.zong.io.selection.Cursor)3 lombok.val (lombok.val)3 MeasureElementWrite (com.xenoage.zong.commands.core.music.MeasureElementWrite)2 Instrument (com.xenoage.zong.core.instrument.Instrument)2 Fraction (com.xenoage.utils.math.Fraction)1 ColumnElementWrite (com.xenoage.zong.commands.core.music.ColumnElementWrite)1 PitchedInstrument (com.xenoage.zong.core.instrument.PitchedInstrument)1 UnpitchedInstrument (com.xenoage.zong.core.instrument.UnpitchedInstrument)1 Chord (com.xenoage.zong.core.music.chord.Chord)1 Clef (com.xenoage.zong.core.music.clef.Clef)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 TraditionalKey (com.xenoage.zong.core.music.key.TraditionalKey)1