Search in sources :

Example 6 with BezierPoint

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

the class OtherReader method readBezierPoint.

@MaybeNull
public static BezierPoint readBezierPoint(MxlPosition mxlPosition, MxlBezier mxlBezier, float tenthsMm, int staffLinesCount, float noteLP, Fraction chordDuration) {
    Float px = mxlPosition.getDefaultX();
    Float py = mxlPosition.getDefaultY();
    Float cx = (mxlBezier != null ? mxlBezier.getBezierX() : null);
    Float cy = (mxlBezier != null ? mxlBezier.getBezierY() : null);
    SP point = null;
    SP control = null;
    float halfNoteWidth = getNoteheadWidth(chordDuration) / 2;
    if (px != null && py != null) {
        float fpx = notNull(px, 0).floatValue();
        float fpy = notNull(py, 0).floatValue();
        // default-x is relative to left side of note. thus, substract the half width
        // of a note (TODO: note type. e.g., whole note is wider)
        point = sp((fpx / 10 - halfNoteWidth) * tenthsMm, (staffLinesCount - 1) * 2 + fpy / 10 * 2 - noteLP);
    }
    if (cx != null && cy != null) {
        float fcx = notNull(cx, 0).floatValue();
        float fcy = notNull(cy, 0).floatValue();
        control = sp((fcx / 10 - halfNoteWidth) * tenthsMm, fcy / 10 * 2);
    }
    if (point != null || control != null)
        return new BezierPoint(point, control);
    else
        return null;
}
Also used : BezierPoint(com.xenoage.zong.core.music.format.BezierPoint) SP(com.xenoage.zong.core.music.format.SP) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Aggregations

BezierPoint (com.xenoage.zong.core.music.format.BezierPoint)6 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)5 SP (com.xenoage.zong.core.music.format.SP)4 SlurStamping (com.xenoage.zong.musiclayout.stampings.SlurStamping)3 VSide (com.xenoage.utils.math.VSide)2 MaybeNull (com.xenoage.utils.annotations.MaybeNull)1 Pitch (com.xenoage.zong.core.music.Pitch)1 WaypointPosition (com.xenoage.zong.core.music.WaypointPosition)1 Slur (com.xenoage.zong.core.music.slur.Slur)1 SlurType (com.xenoage.zong.core.music.slur.SlurType)1 OtherReader.readBezierPoint (com.xenoage.zong.io.musicxml.in.readers.OtherReader.readBezierPoint)1 OtherReader.readVSide (com.xenoage.zong.io.musicxml.in.readers.OtherReader.readVSide)1 OpenSlur (com.xenoage.zong.io.musicxml.in.util.OpenSlur)1 OpenUnnumberedTieds (com.xenoage.zong.io.musicxml.in.util.OpenUnnumberedTieds)1 ContinuedSlur (com.xenoage.zong.musiclayout.continued.ContinuedSlur)1