Ver Fonte

Error checks for invalid pedals
Read no values from musicxml as well.
bug fix for incorrect x value being calculated

Justin Litten há 3 anos atrás
pai
commit
24f00a6555

+ 18 - 9
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetCalculator.ts

@@ -1038,11 +1038,15 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
         endStaffEntry = endMeasure.staffEntries[endMeasure.staffEntries.length - 1];
         // TODO can be undefined if no notes in end measure
       }
-      graphicalPedal.setStartNote(startStaffEntry);
+      if(!graphicalPedal.setStartNote(startStaffEntry)){
+        return;
+      }
 
       if (endStaffLine !== startStaffLine) {
         if(graphicalPedal.pedalSymbol === MusicSymbol.PEDAL_SYMBOL){
-          graphicalPedal.setEndNote(endStaffEntry);
+          if(!graphicalPedal.setEndNote(endStaffEntry)){
+            return;
+          }
           graphicalPedal.setEndMeasure(endMeasure);
           graphicalPedal.ReleaseText = " ";
           graphicalPedal.CalculateBoundingBox();
@@ -1052,8 +1056,9 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
           // pedal starts on the first measure
           const nextPedal: VexFlowPedal = new VexFlowPedal(pedal, nextPedalFirstMeasure.PositionAndShape);
           const firstNote: GraphicalStaffEntry = nextPedalFirstMeasure.staffEntries[0];
-          nextPedal.setStartNote(firstNote);
-          nextPedal.setEndNote(endStaffEntry);
+          if(!nextPedal.setStartNote(firstNote) || !nextPedal.setEndNote(endStaffEntry)){
+            return;
+          }
           graphicalPedal.setEndMeasure(endMeasure);
           endStaffLine.Pedals.push(nextPedal);
           nextPedal.CalculateBoundingBox();
@@ -1065,7 +1070,9 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
             lastMeasureOfFirstShift = endMeasure;
           }
           const lastNoteOfFirstShift: GraphicalStaffEntry = lastMeasureOfFirstShift.staffEntries[lastMeasureOfFirstShift.staffEntries.length - 1];
-          graphicalPedal.setEndNote(lastNoteOfFirstShift);
+          if(!graphicalPedal.setEndNote(lastNoteOfFirstShift)){
+            return;
+          }
           graphicalPedal.setEndMeasure(endMeasure);
 
           const systemsInBetweenCount: number = endStaffLine.ParentMusicSystem.Id - startStaffLine.ParentMusicSystem.Id;
@@ -1093,9 +1100,9 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
                 nextPedalLastMeasure = endMeasure;
                 lastNote = endStaffEntry;
               }
-
-              nextPedal.setStartNote(firstNote);
-              nextPedal.setEndNote(lastNote);
+              if(!nextPedal.setStartNote(firstNote) || !nextPedal.setEndNote(lastNote)){
+                break;
+              }
               graphicalPedal.setEndMeasure(endMeasure);
               nextPedalStaffline.Pedals.push(nextPedal);
               nextPedal.CalculateBoundingBox();
@@ -1106,7 +1113,9 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
           this.calculatePedalSkyBottomLine(graphicalPedal.startVfVoiceEntry, graphicalPedal.endVfVoiceEntry, graphicalPedal, startStaffLine);
         }
       } else {
-        graphicalPedal.setEndNote(endStaffEntry);
+        if(!graphicalPedal.setEndNote(endStaffEntry)){
+          return;
+        }
         graphicalPedal.setEndMeasure(endMeasure);
         graphicalPedal.CalculateBoundingBox();
         this.calculatePedalSkyBottomLine(graphicalPedal.startVfVoiceEntry, graphicalPedal.endVfVoiceEntry, graphicalPedal, startStaffLine);

+ 8 - 0
src/MusicalScore/ScoreIO/MusicSymbolModules/ExpressionReader.ts

@@ -314,9 +314,17 @@ export class ExpressionReader {
                 try {
                     if (pedalNode.attribute("line")?.value === "yes") {
                         line = true;
+                    } else if (pedalNode.attribute("line")?.value === "no"){
+                        line = false;
+                        //No on line implies yes on sign
+                        sign = true;
                     }
                     if (pedalNode.attribute("sign")?.value === "yes") {
                         sign = true;
+                    } else if (pedalNode.attribute("sign")?.value === "no"){
+                        sign = false;
+                        //No on sign implies yes on line
+                        line = true;
                     }
                     switch (pedalNode.attribute("type").value) {
                         case "start":

+ 2 - 2
src/VexFlowPatch/src/pedalmarking.js

@@ -168,7 +168,7 @@ export class PedalMarking extends Element {
         //default to note head begin
         x = note.getNoteHeadBeginX();
       } else {
-        x = this.endStave.end_x + this.endStaveAddedWidth;
+        x = note.getStave().end_x + this.endStaveAddedWidth;
       }
 
       //If this pedal doesn't end a stave...
@@ -190,7 +190,7 @@ export class PedalMarking extends Element {
         //pedal across a single note or just the end note
         if(!is_pedal_depressed){
           //IF we are the end, set the end to the stave end
-          x = this.endStave.end_x + this.endStaveAddedWidth - pedal.render_options.text_margin_right;
+          x = note.getStave().end_x + this.endStaveAddedWidth - pedal.render_options.text_margin_right;
         }
       }