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;
}
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;
}
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();
}
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;
}
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;
}
Aggregations