use of com.xenoage.utils.math.Fraction in project Zong by Xenoage.
the class Context method writeColumnElement.
/**
* Writes the given {@link ColumnElement} at the current measure.
* @param side the side of the measure. If null, the current beat is used.
*/
public void writeColumnElement(ColumnElement element, MeasureSide side) {
Fraction beat = (side == null ? mp.getBeat() : MP.Companion.getUnknownBeat());
new ColumnElementWrite(element, score.getColumnHeader(mp.getMeasure()), beat, side).execute();
}
use of com.xenoage.utils.math.Fraction in project Zong by Xenoage.
the class DirectionReader method readMetronome.
private Direction readMetronome() {
MxlMetronome mxlMetronome = (MxlMetronome) currentMxlDirType;
// compute base beat
Fraction baseBeat = mxlMetronome.getBeatUnit().getDuration();
baseBeat = Duration.INSTANCE.getDuration(baseBeat, mxlMetronome.getDotsCount());
// text: TODO
Tempo tempo = new Tempo(baseBeat, mxlMetronome.getPerMinute());
// TODO tempo.setFont(FontInfoReader.read(currentMxlDirection, defaultFont));
tempo.setPositioning(readPositioning());
return tempo;
}
use of com.xenoage.utils.math.Fraction in project Zong by Xenoage.
the class MeasureReader method readBackupToContext.
private static void readBackupToContext(MxlBackup mxlBackup, Context context) {
// duration
Fraction duration = readDuration(mxlBackup.getDuration(), context.getDivisions()).invert();
// move cursor
context.moveCurrentBeat(duration);
}
use of com.xenoage.utils.math.Fraction in project Zong by Xenoage.
the class MeasureReader method readForwardToContext.
private static void readForwardToContext(MxlForward mxlForward, Context context) {
// duration
Fraction duration = readDuration(mxlForward.getDuration(), context.getDivisions());
// move cursor
context.moveCurrentBeat(duration);
}
use of com.xenoage.utils.math.Fraction in project Zong by Xenoage.
the class TimeMapper method createTimeMap.
public TimeMap createTimeMap() {
// resolution per quarter note
int resolution = score.getDivisions() * resolutionFactor;
// for each play range compute the used beats in each measure column
int tick = 0;
val timeMap = new TimeMapBuilder();
for (int iRep : range(repetitions)) {
val range = repetitions.get(iRep);
for (int iMeasure : range(range.start.getMeasure(), range.end.getMeasure())) {
val usedBeats = getUsedBeats(iMeasure, range);
Fraction lastBeat = null;
for (int iBeat : range(usedBeats)) {
val beat = usedBeats.get(iBeat);
// increase tick by distance between last and this beat
if (lastBeat != null)
tick += beat.sub(lastBeat).mult(resolution * 4).getNumerator();
// add time
timeMap.addTimeNoMs(tick, new RepTime(iRep, Companion.time(iMeasure, beat)));
lastBeat = beat;
}
}
}
return timeMap.build();
}
Aggregations