Skip to content

Commit

Permalink
Multi-measure rests: better handling of vertical serifs
Browse files Browse the repository at this point in the history
  • Loading branch information
hbitteur committed Jan 9, 2024
1 parent 83e1373 commit d9b7691
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ private Map<HorizontalSide, StaffPeak> getSerifPeaks (BeamInter beam,
final Map<HorizontalSide, StaffPeak> serifPeaks = new EnumMap<>(HorizontalSide.class);
final StaffProjector projector = getProjector(staff);
final Rectangle bounds = beam.getBounds();
final int addedChunk = (int) Math.rint(
beam.getHeight() - staff.getMidLine().getThickness());

for (HorizontalSide side : HorizontalSide.values()) {
final int x = (side == HorizontalSide.LEFT) ? bounds.x : bounds.x + bounds.width - 1;
final int addedChunk = (int) Math.rint(
beam.getHeight() - staff.getMidLine().getThickness());
final List<StaffPeak> peaks = projector.processMultiRestSide(x, side, addedChunk);
logger.debug("{} {} {}", beam, side, peaks);

Expand Down
8 changes: 6 additions & 2 deletions src/main/org/audiveris/omr/sheet/grid/StaffProjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -1279,11 +1279,15 @@ public List<StaffPeak> processMultiRestSide (int x,

final int dx = params.verticalSerifWidth;
final int minCount = params.barThreshold / 2;
final int outDer = minCount - params.linesThreshold;
final int inDer = minCount - addedChunk;
final int outDer = Math.max(1, minCount - (3 * params.linesThreshold / 4));
final int inDer = Math.max(1, outDer - addedChunk);
final int minDerUp = (restSide == HorizontalSide.LEFT) ? outDer : inDer;
final int minDerDown = (restSide == HorizontalSide.LEFT) ? inDer : outDer;

// Adjust x to target the middle of expected serif
final int halfDx = (int) Math.ceil(dx * 0.5);
x += (restSide == HorizontalSide.LEFT) ? halfDx / 2 : -halfDx / 2;

final List<StaffPeak> sidePeaks = findPeaksInRange(
x - dx,
x + dx,
Expand Down

0 comments on commit d9b7691

Please sign in to comment.