浏览代码

fix(Metronome): Fix some measures with very long metronome numbers not rendering (#39)

fixes #39
sschmid 3 年之前
父节点
当前提交
60def05564
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/MusicalScore/ScoreIO/MusicSymbolModules/ExpressionReader.ts

+ 4 - 2
src/MusicalScore/ScoreIO/MusicSymbolModules/ExpressionReader.ts

@@ -153,8 +153,10 @@ export class ExpressionReader {
             const tempoAttr: IXmlAttribute = n.attribute("tempo");
             const dynAttr: IXmlAttribute = n.attribute("dynamics");
             if (tempoAttr) {
-                const match: string[] = tempoAttr.value.match(/^(\d+\.?\d{0,9}|\.\d{1,9})$/);
-                this.soundTempo = match !== undefined ? parseInt(match[0], 10) : 100;
+                // const match: string[] = tempoAttr.value.match(/^(\d+\.?\d{0,9}|\.\d{1,9})$/);
+                const match: string[] = tempoAttr.value.match(/^(\d+)(\.\d+)?$/);
+                this.soundTempo = match?.length > 0 ? Math.round(Number.parseFloat(tempoAttr.value)) : 100;
+                //console.log(`value: ${tempoAttr.value}\n  soundTempo: ${this.soundTempo}`);
                 currentMeasure.TempoInBPM = this.soundTempo;
                 if (this.musicSheet.DefaultStartTempoInBpm === 0) {
                     this.musicSheet.DefaultStartTempoInBpm = this.soundTempo;