Skip to content

Commit

Permalink
Small heads can be allowed on standard beams via proper allowSmallHea…
Browse files Browse the repository at this point in the history
…dOnStandardBeam constant
  • Loading branch information
hbitteur committed Jan 9, 2024
1 parent d9b7691 commit 0ea46eb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/main/org/audiveris/omr/image/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ public double evaluate (int x,
Anchor anchor,
DistanceTable distances)
{
if (shape == Shape.NOTEHEAD_VOID_SMALL)
logger.warn("ERROR");
final Point ul = upperLeft(x, y, anchor);

// Loop through template key positions and read related distance.
Expand Down
30 changes: 25 additions & 5 deletions src/main/org/audiveris/omr/sheet/stem/BeamLinker.java
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,21 @@ public String toString ()
.append('}').toString();
}

//~ Static Methods -----------------------------------------------------------------------------

//------------------------------//
// allowSmallHeadOnStandardBeam //
//------------------------------//
/**
* Tell the engine if it must accept to connect a standard beam with a small head.
*
* @return true if allowed
*/
public static boolean allowSmallHeadOnStandardBeam ()
{
return constants.allowSmallHeadOnStandardBeam.isSet();
}

//~ Inner Classes ------------------------------------------------------------------------------

//---------//
Expand Down Expand Up @@ -1326,12 +1341,14 @@ private List<CLinker> filterHeads (List<AbstractBeamInter> siblings)
final HeadInter head = (HeadInter) hInter;
final Shape headShape = head.getShape();

// Today, beam size and head size must match
if (beam.isSmall() != headShape.isSmallHead()) {
if (beam.isVip() || head.isVip()) {
logger.info("VIP no size match between {} and {}", beam, head);
// Small heads may not be allowed on standard beams
if (!allowSmallHeadOnStandardBeam()) {
if (headShape.isSmallHead() && !beam.isSmall()) {
if (beam.isVip() || head.isVip()) {
logger.info("VIP no size match between {} and {}", beam, head);
}
continue;
}
continue;
}

// Check head is far enough from beam group end
Expand Down Expand Up @@ -1778,6 +1795,9 @@ public String toString ()
private static class Constants
extends ConstantSet
{
private final Constant.Boolean allowSmallHeadOnStandardBeam = new Constant.Boolean(
false,
"Should we allow small heads linked with standard beams?");

private final Constant.Ratio maxShorterRatio = new Constant.Ratio(
0.8,
Expand Down
23 changes: 12 additions & 11 deletions src/main/org/audiveris/omr/sig/SigReducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.audiveris.omr.sheet.SystemInfo;
import org.audiveris.omr.sheet.header.StaffHeader;
import org.audiveris.omr.sheet.rhythm.Measure;
import org.audiveris.omr.sheet.stem.BeamLinker;
import org.audiveris.omr.sig.inter.AbstractBeamInter;
import org.audiveris.omr.sig.inter.AbstractChordInter;
import org.audiveris.omr.sig.inter.AbstractFlagInter;
Expand Down Expand Up @@ -133,8 +134,7 @@ public class SigReducer
{ BeamGroupInter.class, LedgerInter.class, SentenceInter.class, WedgeInter.class };

/** Predicate for non-disabled overlap. */
private static final Predicate<Inter> overlapPredicate = (Inter inter) ->
{
private static final Predicate<Inter> overlapPredicate = (Inter inter) -> {
final Class<?> interClass = inter.getClass();

for (Class<?> classe : disabledClasses) {
Expand Down Expand Up @@ -342,7 +342,7 @@ private void analyzeChords ()
}
}

// Head/Beam support or exclusion based on size
// Head/Beam exclusion based on size
for (Entry<Size, Set<Inter>> beamEntry : beams.entrySet()) {
final Size beamSize = beamEntry.getKey();
final Set<Inter> beamSet = beamEntry.getValue();
Expand All @@ -359,12 +359,14 @@ private void analyzeChords ()
}
}
} else {
// Standard beams exclude small (oval) heads
for (Shape small : ShapeSet.HeadsOvalSmall) {
final Set<Inter> smallHeadSet = heads.get(small);
// Standard beams may exclude small (oval) heads
if (!BeamLinker.allowSmallHeadOnStandardBeam()) {
for (Shape small : ShapeSet.HeadsOvalSmall) {
final Set<Inter> smallHeadSet = heads.get(small);

if (smallHeadSet != null) {
exclude(beamSet, smallHeadSet, INCOMPATIBLE);
if (smallHeadSet != null) {
exclude(beamSet, smallHeadSet, INCOMPATIBLE);
}
}
}
}
Expand Down Expand Up @@ -610,7 +612,7 @@ private int checkBeamsHaveBothStems ()
{ BeamPortion.LEFT, BeamPortion.RIGHT }) {
if (beam.getStemOn(portion) == null) {
if (beam.isVip()) {
logger.info("VIP deleting beam lacking stem {} on {}", beam, portion);
logger.info("VIP deleting {} lacking stem on {}", beam, portion);
}

beam.remove();
Expand Down Expand Up @@ -1515,8 +1517,7 @@ private void fixSharedLedger (LedgerInter ledger,
logger.info("Owner: {} other: {}", owner, other);

ledgers.stream().forEach(inter -> inter.setStaff(owner));
heads.stream().forEach(inter ->
{
heads.stream().forEach(inter -> {
final HeadInter h = (HeadInter) inter;
if (h.getStaff() != owner) {
h.setPitch(null); // To force new pitch computation
Expand Down

0 comments on commit 0ea46eb

Please sign in to comment.