Skip to content

Commit

Permalink
First steps recognizing diamond (filled & hollow) percussion notehead…
Browse files Browse the repository at this point in the history
…s and getting stem/beam connections
  • Loading branch information
brian-math committed Apr 19, 2022
1 parent 1e34322 commit 8d0f4d2
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 15 deletions.
8 changes: 5 additions & 3 deletions src/main/org/audiveris/omr/glyph/Shape.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,12 @@ public enum Shape
//
// Noteheads ---
//
NOTEHEAD_CROSS("Ghost node with rhythmic value but no discernible pitch"),
NOTEHEAD_BLACK("Filled node head for quarters and less"),
NOTEHEAD_CROSS("Ghost note with rhythmic value but no discernible pitch"),
NOTEHEAD_DIAMOND_FILLED("Filled diamond shape note head for unpitched percussion"),
NOTEHEAD_DIAMOND_VOID("Hollow diamond shape note head for unpitched percussion"),
NOTEHEAD_BLACK("Filled note head for quarters and less"),
NOTEHEAD_BLACK_SMALL("Small filled note head for grace or cue"),
NOTEHEAD_VOID("Hollow node head for halves"),
NOTEHEAD_VOID("Hollow note head for halves"),
NOTEHEAD_VOID_SMALL("Small hollow note head for grace or cue"),

//
Expand Down
17 changes: 16 additions & 1 deletion src/main/org/audiveris/omr/glyph/ShapeSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,13 @@ public class ShapeSet

/** All black note heads. */
public static final EnumSet<Shape> BlackNoteHeads = EnumSet.of(
NOTEHEAD_DIAMOND_FILLED,
NOTEHEAD_BLACK,
NOTEHEAD_BLACK_SMALL);

/** All void note heads. */
public static final EnumSet<Shape> VoidNoteHeads = EnumSet.of(
NOTEHEAD_DIAMOND_VOID,
NOTEHEAD_VOID,
NOTEHEAD_VOID_SMALL);

Expand All @@ -195,6 +197,8 @@ public class ShapeSet
/** All heads with a stem. */
public static final EnumSet<Shape> StemHeads = EnumSet.of(
NOTEHEAD_CROSS,
NOTEHEAD_DIAMOND_FILLED,
NOTEHEAD_DIAMOND_VOID,
NOTEHEAD_BLACK,
NOTEHEAD_BLACK_SMALL,
NOTEHEAD_VOID,
Expand All @@ -206,6 +210,8 @@ public class ShapeSet
WHOLE_NOTE,
WHOLE_NOTE_SMALL,
NOTEHEAD_CROSS,
NOTEHEAD_DIAMOND_FILLED,
NOTEHEAD_DIAMOND_VOID,
NOTEHEAD_BLACK,
NOTEHEAD_BLACK_SMALL,
NOTEHEAD_VOID,
Expand Down Expand Up @@ -765,6 +771,8 @@ public static String getPhysicalShapeNamesString ()
public static EnumSet<Shape> getTemplateNotes (Sheet sheet)
{
final EnumSet<Shape> set = EnumSet.of(
NOTEHEAD_DIAMOND_FILLED,
NOTEHEAD_DIAMOND_VOID,
NOTEHEAD_CROSS,
NOTEHEAD_BLACK,
NOTEHEAD_VOID,
Expand All @@ -791,8 +799,11 @@ public static EnumSet<Shape> getTemplateNotes (Sheet sheet)
set.remove(WHOLE_NOTE_SMALL);
}

/** For now, use ProcessingSwitch.crossHeads for all unpitched percussion note heads */
if (!switches.getValue(ProcessingSwitch.crossHeads)) {
set.remove(NOTEHEAD_CROSS);
set.remove(NOTEHEAD_DIAMOND_FILLED);
set.remove(NOTEHEAD_DIAMOND_VOID);
}

return set;
Expand Down Expand Up @@ -838,6 +849,8 @@ public static EnumSet<Shape> getStemTemplateNotes (Sheet sheet)
{
final EnumSet<Shape> set = EnumSet.of(
NOTEHEAD_CROSS,
NOTEHEAD_DIAMOND_FILLED,
NOTEHEAD_DIAMOND_VOID,
NOTEHEAD_BLACK,
NOTEHEAD_VOID,
NOTEHEAD_BLACK_SMALL,
Expand All @@ -859,6 +872,8 @@ public static EnumSet<Shape> getStemTemplateNotes (Sheet sheet)

if (!switches.getValue(ProcessingSwitch.crossHeads)) {
set.remove(NOTEHEAD_CROSS);
set.remove(NOTEHEAD_DIAMOND_FILLED);
set.remove(NOTEHEAD_DIAMOND_VOID);
}

return set;
Expand All @@ -875,7 +890,7 @@ public static EnumSet<Shape> getStemTemplateNotes (Sheet sheet)
*/
public static EnumSet<Shape> getVoidTemplateNotes (Sheet sheet)
{
final EnumSet<Shape> set = EnumSet.of(NOTEHEAD_VOID, WHOLE_NOTE, NOTEHEAD_VOID_SMALL);
final EnumSet<Shape> set = EnumSet.of(NOTEHEAD_VOID, WHOLE_NOTE, NOTEHEAD_VOID_SMALL, NOTEHEAD_DIAMOND_VOID);

if (sheet == null) {
return set;
Expand Down
10 changes: 9 additions & 1 deletion src/main/org/audiveris/omr/image/TemplateFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.audiveris.omr.constant.Constant;
import org.audiveris.omr.constant.ConstantSet;
import org.audiveris.omr.glyph.Shape;
import static org.audiveris.omr.glyph.Shape.NOTEHEAD_DIAMOND_VOID;
import static org.audiveris.omr.glyph.Shape.NOTEHEAD_VOID;
import static org.audiveris.omr.glyph.Shape.NOTEHEAD_VOID_SMALL;
import static org.audiveris.omr.glyph.Shape.WHOLE_NOTE;
Expand Down Expand Up @@ -101,7 +102,8 @@ public class TemplateFactory
private static final TemplateFactory INSTANCE = new TemplateFactory();

/** All shapes with hole(s). */
private static final EnumSet shapesWithHoles = EnumSet.of(NOTEHEAD_VOID,
private static final EnumSet shapesWithHoles = EnumSet.of(NOTEHEAD_DIAMOND_VOID,
NOTEHEAD_VOID,
NOTEHEAD_VOID_SMALL,
WHOLE_NOTE,
WHOLE_NOTE_SMALL);
Expand Down Expand Up @@ -721,6 +723,12 @@ private Set<Point> getBorderPoints (BufferedImage img)
private static int getCode (Shape shape)
{
switch (shape) {
case NOTEHEAD_DIAMOND_FILLED:
return 226;

case NOTEHEAD_DIAMOND_VOID:
return 225;

case NOTEHEAD_CROSS:
return 192;

Expand Down
2 changes: 2 additions & 0 deletions src/main/org/audiveris/omr/sheet/curve/Skeleton.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ public BufferedImage buildSkeleton ()
Shape.WHOLE_NOTE,
Shape.WHOLE_NOTE_SMALL,
Shape.NOTEHEAD_CROSS,
Shape.NOTEHEAD_DIAMOND_FILLED,
Shape.NOTEHEAD_DIAMOND_VOID,
Shape.NOTEHEAD_BLACK,
Shape.NOTEHEAD_BLACK_SMALL,
Shape.NOTEHEAD_VOID,
Expand Down
2 changes: 2 additions & 0 deletions src/main/org/audiveris/omr/sheet/symbol/InterFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,8 @@ private static Inter doCreateManual (Shape shape,

// Noteheads
case NOTEHEAD_CROSS:
case NOTEHEAD_DIAMOND_FILLED:
case NOTEHEAD_DIAMOND_VOID:
case NOTEHEAD_BLACK:
case NOTEHEAD_BLACK_SMALL:
case NOTEHEAD_VOID:
Expand Down
22 changes: 12 additions & 10 deletions src/main/org/audiveris/omr/sig/SigReducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,25 +407,27 @@ private void analyzeChords ()
}

// Standard beams support black heads (not void)
Set<Inter> blackHeadSet = heads.get(Shape.NOTEHEAD_BLACK);
for (Shape shape : new Shape[]{Shape.NOTEHEAD_BLACK, Shape.NOTEHEAD_DIAMOND_FILLED}) {
Set<Inter> blackHeadSet = heads.get(shape);

if (blackHeadSet != null) {
for (Inter beam : beamSet) {
BeamStemRelation bs = (BeamStemRelation) sig.getRelation(
if (blackHeadSet != null) {
for (Inter beam : beamSet) {
BeamStemRelation bs = (BeamStemRelation) sig.getRelation(
beam,
stem,
BeamStemRelation.class);

for (Inter head : blackHeadSet) {
if (sig.getRelation(beam, head, BeamHeadRelation.class) == null) {
// Use average of beam-stem and head-stem relation grades
HeadStemRelation hs = (HeadStemRelation) sig.getRelation(
for (Inter head : blackHeadSet) {
if (sig.getRelation(beam, head, BeamHeadRelation.class) == null) {
// Use average of beam-stem and head-stem relation grades
HeadStemRelation hs = (HeadStemRelation) sig.getRelation(
head,
stem,
HeadStemRelation.class);
double grade = (bs.getGrade() + hs.getGrade()) / 2;
double grade = (bs.getGrade() + hs.getGrade()) / 2;

///sig.addEdge(beam, head, new BeamHeadRelation(grade));
///sig.addEdge(beam, head, new BeamHeadRelation(grade));
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/org/audiveris/omr/sig/inter/AbstractNoteInter.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ private static EnumMap<Shape, Rational> buildShapeDurations ()

map.put(Shape.QUARTER_REST, QUARTER_DURATION);
map.put(Shape.NOTEHEAD_CROSS, QUARTER_DURATION);
map.put(Shape.NOTEHEAD_DIAMOND_FILLED, QUARTER_DURATION);
map.put(Shape.NOTEHEAD_DIAMOND_VOID, QUARTER_DURATION);
map.put(Shape.NOTEHEAD_BLACK, QUARTER_DURATION);
map.put(Shape.NOTEHEAD_BLACK_SMALL, QUARTER_DURATION);

Expand Down
2 changes: 2 additions & 0 deletions src/main/org/audiveris/omr/ui/symbol/Symbols.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ private static void assignSymbols ()
sym.put(NON_DRAGGABLE, new NonDraggableSymbol(192));
small(NOTEHEAD_BLACK_SMALL, 207);
mapShape(NOTEHEAD_CROSS, 192);
mapShape(NOTEHEAD_DIAMOND_FILLED, 226);
mapShape(NOTEHEAD_DIAMOND_VOID, 225);
mapShape(NOTEHEAD_VOID, 250);
small(NOTEHEAD_VOID_SMALL, 250);
// mapShape(NO_LEGAL_TIME);
Expand Down

0 comments on commit 8d0f4d2

Please sign in to comment.