Browse Source

merge osmd-public/develop: fix bold words in XML not rendered bold, add some tempo expressions, fix a noteflight sample error

sschmidTU 1 year ago
parent
commit
c49b636b43

+ 6 - 1
src/MusicalScore/Graphical/GraphicalMusicSheet.ts

@@ -408,10 +408,15 @@ export class GraphicalMusicSheet {
      */
     public GetInterpolatedIndexInVerticalContainers(musicTimestamp: Fraction): number {
         const containers: VerticalGraphicalStaffEntryContainer[] = this.verticalGraphicalStaffEntryContainers;
+        if (containers.length === 1) {
+            return 0; // this fixes an error with Noteflight samples, see below (#1473). It may also be faster.
+        }
         let leftIndex: number = 0;
         let rightIndex: number = containers.length - 1;
         let leftTS: Fraction = undefined;
         let rightTS: Fraction = undefined;
+        // TODO AbsoluteTimestamp can be NaN in some erroneous MusicXML files like from Noteflight, see omd issue #1473
+        //   (though in the sample tested, there is only one container, so above containers.length === 1 prevents the error)
         if (musicTimestamp.lte(containers[containers.length - 1].AbsoluteTimestamp)) {
             while (rightIndex - leftIndex > 1) {
                 const middleIndex: number = Math.floor((rightIndex + leftIndex) / 2);
@@ -446,7 +451,7 @@ export class GraphicalMusicSheet {
 
         // estimate the interpolated index
         const foundIndex: number = rightIndex - (diffTS / diff);
-        return Math.min(foundIndex, this.verticalGraphicalStaffEntryContainers.length);
+        return Math.min(foundIndex, this.verticalGraphicalStaffEntryContainers.length - 1);
     }
 
     /**

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

@@ -576,6 +576,13 @@ export class ExpressionReader {
                 fontStyle = FontStyles.Italic;
             }
         }
+        const fontWeightAttr: Attr = wordsNode.attribute("font-weight");
+        if (fontWeightAttr) {
+            const fontWeightText: string = fontWeightAttr.value;
+            if (fontWeightText === "bold") {
+                fontStyle = FontStyles.Bold;
+            }
+        }
         let defaultYXml: number;
         if (currentMeasure.Rules.PlaceWordsInsideStafflineFromXml) {
             const defaultYString: string = wordsNode.attribute("default-y")?.value;

+ 3 - 3
src/MusicalScore/VoiceData/Expressions/InstantaneousTempoExpression.ts

@@ -30,12 +30,12 @@ export class InstantaneousTempoExpression extends AbstractTempoExpression {
     private static listInstantaneousTempoAdagietto: string[] = ["Adagietto", "Ziemlich ruhig", "Ziemlich langsam", "rather slow"]; //  }), TempoEnum.adagietto);
     private static listInstantaneousTempoAndanteModerato: string[] = ["Andante moderato"]; //  }), TempoEnum.andanteModerato);
     private static listInstantaneousTempoAndante: string[] = ["Andante", "Gehend", "Schreitend", "at a walking pace"]; //  }), TempoEnum.andante);
-    private static listInstantaneousTempoAndantino: string[] = ["Andantino"]; //  }), TempoEnum.andantino);
+    private static listInstantaneousTempoAndantino: string[] = ["Andantino", "Maestoso"]; //  }), TempoEnum.andantino);
     private static listInstantaneousTempoModerato: string[] = ["Moderato", "Mäßig", "Modéré", "moderately"]; //  }), TempoEnum.moderato);
-    private static listInstantaneousTempoAllegretto: string[] = ["Allegretto", "fast"]; //  }), TempoEnum.allegretto);
+    private static listInstantaneousTempoAllegretto: string[] = ["Allegretto", "Animato", "fast"]; //  }), TempoEnum.allegretto);
     private static listInstantaneousTempoAllegroModerato: string[] = ["Allegro moderato"]; //  }), TempoEnum.allegroModerato);
     private static listInstantaneousTempoAllegro: string[] = ["Allegro", "Rapide", "Vite", "Rasch", "Schnell", "Fröhlich"]; //  }), TempoEnum.allegro);
-    private static listInstantaneousTempoVivace: string[] = ["Vivace", "Lebhaft", "Lebendig", "lively and fast"]; //  }), TempoEnum.vivace);
+    private static listInstantaneousTempoVivace: string[] = ["Vivace", "Allegro Assai", "Lebhaft", "Lebendig", "lively and fast"]; //  }), TempoEnum.vivace);
     private static listInstantaneousTempoVivacissimo: string[] = ["Vivacissimo", "Sehr lebhaft", "Sehr lebendig"]; //  }), TempoEnum.vivacissimo);
     private static listInstantaneousTempoAllegrissimo: string[] = ["Allegrissimo", "very fast"]; //  }), TempoEnum.allegrissimo);
     private static listInstantaneousTempoPresto: string[] = ["Presto", "Sehr schnell", "Geschwind"]; //  }), TempoEnum.presto);