use of com.xenoage.zong.musiclayout.notator.beam.lines.BeamRules in project Zong by Xenoage.
the class SingleStaffBeamPlacer method shorten.
/**
* Shortens the stem lengths of the given placement candidate by one quarter space,
* if possible and when no stem gets shorter than the {@link BeamRules} allow it.
* This rule not found explicitly mentioned by Ross, but applies to many examples and
* conforms to the general rule that beamed stems tend to be shortened (p. 103, last
* paragraph). See for example:
* <ul>
* <li>p104 r1 c1: could be 3.5/sit, but is 3.25/straddle</li>
* <li>p104 r6 c1: could be 3.75/straddle and 3.5/hang, but is 3.5/sit and 3.25/straddle</li>
* <li>p105 r1 c2: could be 3.5/hang, but is 3.25/staddle</li>
* </ul>
*/
Placement shorten(Placement candidate, StemDirection stemDir, BeamedStems stems, int beamLinesCount, StaffLines staffLines) {
// shorten
Placement shorterCandidate = new Placement(candidate.leftEndLp - stemDir.getSign() * 0.5f, candidate.rightEndLp - stemDir.getSign() * 0.5f);
// stems still long enough?
float slantIs = (shorterCandidate.rightEndLp - shorterCandidate.leftEndLp) / 2;
BeamRules beamRules = BeamRules.getRules(beamLinesCount);
for (val stem : stems) {
float distanceToBeam = abs(getDistanceToLineLp(stem.noteSlp.lp, stem.xIs, slantIs, stems.leftXIs, stems.rightXIs) - shorterCandidate.leftEndLp) / 2;
if (distanceToBeam < beamRules.getMinimumStemLengthIs())
// shortening not possible
return candidate;
}
// edges correct?
if (isPlacementCorrect(shorterCandidate, stemDir, beamLinesCount, staffLines))
// success
return shorterCandidate;
else
// shortening not possible
return candidate;
}
use of com.xenoage.zong.musiclayout.notator.beam.lines.BeamRules in project Zong by Xenoage.
the class BeamNotator method compute.
@MaybeNull
public BeamNotation compute(Beam beam, Notations notations) {
// compute fragments
List<Fragments> fragments = beamFragmenter.compute(beam);
// get minimum stem length and gap
BeamRules beamRules = BeamRules.getRules(beam);
float gapIs = beamRules.getGapIs();
// collect chords
List<ChordNotation> chords = notations.getBeamChords(beam);
// create notation
BeamNotation beamNotation = new BeamNotation(beam, beam.getMP(), fragments, gapIs, chords);
return beamNotation;
}
Aggregations