Преглед на файлове

cherry pick audio player 820ab67

audio player issue 48
sschmid преди 4 години
родител
ревизия
69bdd55796

+ 15 - 0
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -555,6 +555,20 @@ export class InstrumentReader {
           // TODO do we need to process bars with left location too?
         } else if (xmlNode.name === "sound") {
           // (*) MetronomeReader.readTempoInstruction(xmlNode, this.musicSheet, this.currentXmlMeasureIndex);
+          try {
+            if (xmlNode.hasAttributes && xmlNode.attribute("tempo") !== undefined) {
+
+                const tempo: number = parseFloat(xmlNode.attribute("tempo").value);
+
+                // should set the PlaybackSettings only at first Measure
+                if (this.currentXmlMeasureIndex === 0) {
+                    this.musicSheet.DefaultStartTempoInBpm = tempo;
+                    this.musicSheet.HasBPMInfo = true;
+                }
+            }
+          } catch (e) {
+            log.debug("InstrumentReader.readTempoInstruction", e);
+          }
         } else if (xmlNode.name === "harmony") {
           // new chord, could be second chord on same staffentry/note
           this.openChordSymbolContainers.push(ChordSymbolReader.readChordSymbol(xmlNode, this.musicSheet, this.activeKey));
@@ -588,6 +602,7 @@ export class InstrumentReader {
       // next measures will automatically inherit that value
       if (!this.musicSheet.HasBPMInfo) {
         this.currentMeasure.TempoInBPM = 120;
+        this.musicSheet.DefaultStartTempoInBpm = 120;
       } else if (currentMeasure.TempoInBPM === 0) {
         this.currentMeasure.TempoInBPM = this.previousMeasure.TempoInBPM;
       }

+ 1 - 1
src/MusicalScore/ScoreIO/MusicSheetReader.ts

@@ -188,7 +188,7 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
          afterSheetReadingModule.calculate(this.musicSheet);
         }
 
-        this.musicSheet.DefaultStartTempoInBpm = this.musicSheet.SourceMeasures[0].TempoInBPM;
+        //this.musicSheet.DefaultStartTempoInBpm = this.musicSheet.SourceMeasures[0].TempoInBPM;
         this.musicSheet.userStartTempoInBPM = this.musicSheet.userStartTempoInBPM || this.musicSheet.DefaultStartTempoInBpm;
 
         return this.musicSheet;

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

@@ -143,6 +143,9 @@ export class ExpressionReader {
                 const match: string[] = tempoAttr.value.match(/\d+/);
                 this.soundTempo = match !== undefined ? parseInt(match[0], 10) : 100;
                 currentMeasure.TempoInBPM = this.soundTempo;
+                if (this.musicSheet.DefaultStartTempoInBpm === 0) {
+                    this.musicSheet.DefaultStartTempoInBpm = this.soundTempo;
+                }
                 this.musicSheet.HasBPMInfo = true;
                 isTempoInstruction = true;
             }
@@ -179,6 +182,9 @@ export class ExpressionReader {
                                                      true);
                 this.soundTempo = bpmNumber;
                 currentMeasure.TempoInBPM = this.soundTempo;
+                if (this.musicSheet.DefaultStartTempoInBpm === 0) {
+                    this.musicSheet.DefaultStartTempoInBpm = this.soundTempo;
+                }
                 this.musicSheet.HasBPMInfo = true;
                 instantaneousTempoExpression.dotted = dotted;
                 instantaneousTempoExpression.beatUnit = beatUnit.value;