Explorar el Código

autoBeam: fix noteIsQuarterOrLonger check

part of #574
Simon Schmid hace 5 años
padre
commit
0d54c484f1

+ 1 - 1
src/Common/DataObjects/Fraction.ts

@@ -302,7 +302,7 @@ export class Fraction {
     }
   }
 
-  private static FloatInaccuracyTolerance: number = 0.0001; // inaccuracy allowed when comparing Fraction.RealValues, because of floating point inaccuracy
+  public static FloatInaccuracyTolerance: number = 0.0001; // inaccuracy allowed when comparing Fraction.RealValues, because of floating point inaccuracy
 
   public isOnBeat(timeSignature: Fraction): boolean { // use sourceMeasure.ActiveTimeSignature as timeSignature
       const beatDistance: number = this.distanceFromBeat(timeSignature);

+ 3 - 1
src/MusicalScore/Graphical/VexFlow/VexFlowMeasure.ts

@@ -665,9 +665,11 @@ export class VexFlowMeasure extends GraphicalMeasure {
                 const gNote: GraphicalNote = gve.notes[0]; // TODO check for all notes within the graphical voice entry
                 const isOnBeat: boolean = staffEntry.relInMeasureTimestamp.isOnBeat(timeSignature);
                 const haveTwoOrMoreNotesToBeamAlready: boolean = consecutiveBeamableNotes.length >= 2;
+                //const noteIsQuarterOrLonger: boolean = gNote.sourceNote.Length.CompareTo(new Fraction(1, 4)) >= 0; // trusting Fraction class, no float check
+                const noteIsQuarterOrLonger: boolean = gNote.sourceNote.Length.RealValue - new Fraction(1, 4).RealValue > (-Fraction.FloatInaccuracyTolerance);
                 const unbeamableNote: boolean =
                     gve.parentVoiceEntry.IsGrace || // don't beam grace notes
-                    gNote.sourceNote.Length.CompareTo(new Fraction(1, 4)) === 1 || // don't beam quarter or longer notes
+                    noteIsQuarterOrLonger || // don't beam quarter or longer notes
                     beamedNotes.contains(vfStaveNote);
                 if (unbeamableNote || isOnBeat) { // end beam
                     if (haveTwoOrMoreNotesToBeamAlready) {