Search in sources :

Example 1 with OpenSlur

use of com.xenoage.zong.io.musicxml.in.util.OpenSlur in project Zong by Xenoage.

the class SlurReader method readToContext.

public static void readToContext(Chord chord, int noteIndex, int staffIndexInPart, Context context, MxlSlurOrTied mxlSlur) {
    Pitch pitch = chord.getNotes().get(noteIndex).getPitch();
    float noteLP = context.getMusicContext(staffIndexInPart).getLp(pitch);
    // type
    SlurType type = (mxlSlur.getElementType() == MxlElementType.Slur ? SlurType.Slur : SlurType.Tie);
    // number (tied does usually not use a number, but is distinguished by pitch)
    Integer number = mxlSlur.getNumber();
    BezierPoint bezierPoint = readBezierPoint(mxlSlur.getPosition(), mxlSlur.getBezier(), context.getTenthMm(), context.getStaffLinesCount(staffIndexInPart), noteLP, chord.getDuration());
    VSide side = readVSide(mxlSlur.getPlacement());
    // waypoint
    SlurWaypoint wp = new SlurWaypoint(chord, noteIndex, bezierPoint);
    if (type == SlurType.Tie && number == null) {
        // unnumbered tied
        OpenUnnumberedTieds openTieds = context.getOpenElements().getOpenUnnumberedTies();
        if (mxlSlur.getType() == MxlStartStopContinue.Start) {
            openTieds.startTied(wp, side);
        } else if (mxlSlur.getType() == MxlStartStopContinue.Stop) {
            OpenSlur openTied = openTieds.stopTied(wp, side, context);
            if (openTied != null)
                context.createSlur(openTied);
        }
    } else {
        // numbered
        WaypointPosition wpPos;
        if (mxlSlur.getType() == MxlStartStopContinue.Start)
            wpPos = WaypointPosition.Start;
        else if (mxlSlur.getType() == MxlStartStopContinue.Stop)
            wpPos = WaypointPosition.Stop;
        else
            wpPos = WaypointPosition.Continue;
        context.registerSlur(type, wpPos, number, wp, side);
    }
}
Also used : BezierPoint(com.xenoage.zong.core.music.format.BezierPoint) OtherReader.readBezierPoint(com.xenoage.zong.io.musicxml.in.readers.OtherReader.readBezierPoint) WaypointPosition(com.xenoage.zong.core.music.WaypointPosition) OpenSlur(com.xenoage.zong.io.musicxml.in.util.OpenSlur) Pitch(com.xenoage.zong.core.music.Pitch) SlurType(com.xenoage.zong.core.music.slur.SlurType) OtherReader.readVSide(com.xenoage.zong.io.musicxml.in.readers.OtherReader.readVSide) VSide(com.xenoage.utils.math.VSide) SlurWaypoint(com.xenoage.zong.core.music.slur.SlurWaypoint) OpenUnnumberedTieds(com.xenoage.zong.io.musicxml.in.util.OpenUnnumberedTieds)

Aggregations

VSide (com.xenoage.utils.math.VSide)1 Pitch (com.xenoage.zong.core.music.Pitch)1 WaypointPosition (com.xenoage.zong.core.music.WaypointPosition)1 BezierPoint (com.xenoage.zong.core.music.format.BezierPoint)1 SlurType (com.xenoage.zong.core.music.slur.SlurType)1 SlurWaypoint (com.xenoage.zong.core.music.slur.SlurWaypoint)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