Search in sources :

Example 1 with Direction

use of com.xenoage.zong.musiclayout.spacer.beam.Direction in project Zong by Xenoage.

the class SingleStaffBeamSlanter method computeNormal.

/**
 * Computes the slant for beams with normal horizontal spacing.
 */
public Slant computeNormal(float firstNoteLp, float lastNoteLp) {
    // Ross, p. 111 (and p. 101)
    int interval = round(abs(firstNoteLp - lastNoteLp));
    Direction dir = (lastNoteLp > firstNoteLp ? Ascending : Descending);
    switch(interval) {
        // unison
        case 0:
            return horizontalSlant;
        // 2nd
        case 1:
            return slantIs(0.25f, dir);
        // 3rd
        case 2:
            return slantIs(0.5f, 1, dir);
        // 4th
        case 3:
            return slantIs(0.5f, 1.25f, dir);
        // 5th
        case 4:
            return slantIs(1.25f, dir);
        // 6th
        case 5:
            return slantIs(1.25f, 1.5f, dir);
        // 7th
        case 6:
            return slantIs(1.25f, 1.75f, dir);
        // 8th or higher
        default:
            return slantIs(1.25f, 2, dir);
    }
}
Also used : StemDirection(com.xenoage.zong.core.music.chord.StemDirection) Direction(com.xenoage.zong.musiclayout.spacer.beam.Direction)

Example 2 with Direction

use of com.xenoage.zong.musiclayout.spacer.beam.Direction in project Zong by Xenoage.

the class SingleStaffBeamSlanter method computeClose.

/**
 * Computes the slant for closely spaced beams.
 */
Slant computeClose(BeamedStems stems, StemDirection stemDir) {
    // Ross, p. 112: beams in close spacing slant only 1/4 to 1/2 space
    int dictatorLp = Math.round(stemDir == Up ? stems.getMaxNoteLp() : stems.getMinNoteLp());
    Direction dir = (stems.rightNoteLp > stems.leftNoteLp ? Ascending : Descending);
    // if dictator is on a staff line, use slant of 1/4 space
    if (dictatorLp % 2 == 0 || abs(stems.rightNoteLp - stems.leftNoteLp) <= 1)
        // on staff (Ross p. 112) or 2nd interval (Ross p. 111)
        return slantIs(0.25f, dir);
    else
        return slantIs(0.5f, dir);
}
Also used : StemDirection(com.xenoage.zong.core.music.chord.StemDirection) Direction(com.xenoage.zong.musiclayout.spacer.beam.Direction)

Aggregations

StemDirection (com.xenoage.zong.core.music.chord.StemDirection)2 Direction (com.xenoage.zong.musiclayout.spacer.beam.Direction)2