use of com.xenoage.zong.core.music.time.TimeSignature in project Zong by Xenoage.
the class VoicesBeatOffsetterTest method createTestScore3VoicesIncomplete.
private Score createTestScore3VoicesIncomplete() {
Score score = new Score();
score.getFormat().setInterlineSpace(2);
Cursor cursor = new Cursor(score, mp0, true);
cursor.write(new TimeSignature(Companion.getTime_4_4()));
// 2: half note, 4: quarter note, 8: eighth note, 3: quarter triplet, x: missing (empty)
// voice 1: | 4 4 4 8 xxx| (staff 1)
// voice 2: | 8 8 8 8 4 xxxxxx| (staff 1)
// voice 3: | 3 3 3 8 xxxxxxxxx| (staff 2)
// voice 1
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 4)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 4)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 4)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
// voice 2
cursor.setMp(atElement(0, 0, 1, 0));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 4)));
// voice 3
cursor.setMp(atElement(0, 0, 2, 0));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 6)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 6)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 6)));
cursor.write(chord(Companion.pi(0, 0, 0), Companion.fr(1, 8)));
return score;
}
use of com.xenoage.zong.core.music.time.TimeSignature in project Zong by Xenoage.
the class ScoreTest method getMeasureBeatsTest.
@Test
public void getMeasureBeatsTest() {
Score score = ScoreFactory.create1Staff4Measures();
// first measure: no time, 1/4 used
score.getVoice(atVoice(0, 0, 0)).addElement(new Rest(Companion.fr(1, 4)));
// second measure: 3/4 time, 2/4 used
score.getColumnHeader(1).setTime(new TimeSignature(TimeType.Companion.getTime_3_4()));
score.getVoice(atVoice(0, 1, 0)).addElement(new Rest(Companion.fr(1, 4)));
score.getVoice(atVoice(0, 1, 0)).addElement(new Rest(Companion.fr(1, 4)));
// third measure: still 3/4 time, 1/4 used
score.getVoice(atVoice(0, 2, 0)).addElement(new Rest(Companion.fr(1, 4)));
// check
assertEquals(Companion.fr(1, 4), score.getMeasureBeats(0));
assertEquals(Companion.fr(3, 4), score.getMeasureBeats(1));
assertEquals(Companion.fr(3, 4), score.getMeasureBeats(2));
}
use of com.xenoage.zong.core.music.time.TimeSignature 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.core.music.time.TimeSignature in project Zong by Xenoage.
the class AttributesReader method readToContext.
/**
* Reads the given attributes element.
*/
public void readToContext(Context context) {
// divisions
Integer divisions = mxlAttributes.getDivisions();
if (divisions != null)
context.setDivisions(divisions);
// key signature
Key key = readKey(mxlAttributes.getKey());
if (key != null)
context.writeColumnElement(key);
// time signature
TimeSignature time = readTime(mxlAttributes.getTime());
if (// TODO: attribute "number" for single staves
time != null)
context.writeColumnElement(time);
// clefs
if (mxlAttributes.getClefs() != null) {
for (MxlClef mxlClef : mxlAttributes.getClefs()) {
ClefReader clefReader = new ClefReader(mxlClef);
Clef clef = clefReader.read();
int staff = clefReader.readStaff();
if (clef != null)
context.writeMeasureElement(clef, staff);
}
}
// transposition changes - TODO: clean solution for instrument changes
PitchedInstrument instrument = readTransposedInstrument(mxlAttributes.getTranspose());
if (instrument != null) {
// write to all staves of this part
for (int staff = 0; staff < context.getPartStaffIndices().getCount(); staff++) context.writeMeasureElement(new InstrumentChange(instrument), staff);
}
}
use of com.xenoage.zong.core.music.time.TimeSignature in project Zong by Xenoage.
the class AttributesReader method readTime.
private TimeSignature readTime(MxlTime mxlTime) {
if (mxlTime == null)
return null;
TimeSignature time = null;
MxlTimeContentType type = mxlTime.getContent().getTimeContentType();
if (type == MxlTimeContentType.SenzaMisura) {
// senza misura
time = new TimeSignature(Companion.getTimeSenzaMisura());
} else if (type == MxlTimeContentType.NormalTime) {
// normal time
MxlNormalTime mxlNormalTime = (MxlNormalTime) mxlTime.getContent();
// common, cut or fractional?
if (mxlTime.getSymbol() == MxlTimeSymbol.Cut)
time = new TimeSignature(TimeType.Companion.getTimeAllaBreve());
else if (mxlTime.getSymbol() == MxlTimeSymbol.Common)
time = new TimeSignature(TimeType.Companion.getTimeCommon());
else
// otherwise, we currently support only normal fractional time signatures
time = new TimeSignature(Companion.timeType(mxlNormalTime.getBeats(), mxlNormalTime.getBeatType()));
}
return time;
}
Aggregations