|
@@ -1286,8 +1286,24 @@ export class PlaybackManager implements IPlaybackParametersListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /** Returns the duration of the piece in ms. Including repeats. */
|
|
|
|
|
|
+ /** Returns the duration of the piece in ms (by each measure's bpm, without repeats).
|
|
|
|
+ * The result may be inaccurate if you haven't set the bpm to the first measure's bpm before playback.
|
|
|
|
+ * In that case, getSheetDurationInMsEvenBpm() can be more accurate (previous version of this method)
|
|
|
|
+ */
|
|
public getSheetDurationInMs(): number {
|
|
public getSheetDurationInMs(): number {
|
|
|
|
+ let totalDuration: number = 0;
|
|
|
|
+ // code similar to PlaybackSettings.getDurationInMilliseconds()
|
|
|
|
+ const beatRealValue: number = 1.0 / 4.0;
|
|
|
|
+ for (const measure of this.musicPartManager.MusicSheet.SourceMeasures) {
|
|
|
|
+ const beatLengthInMs: number = 60000.0 / measure.TempoInBPM;
|
|
|
|
+ totalDuration += measure.Duration.RealValue * beatLengthInMs / beatRealValue;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return totalDuration;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /** Returns the sheet duration of the piece in ms given the tempo set via setBpm() doesn't change. */
|
|
|
|
+ public getSheetDurationInMsEvenBpm(): number {
|
|
return this.timingSource.getDurationInMs(this.musicPartManager.MusicSheet.SheetEndTimestamp);
|
|
return this.timingSource.getDurationInMs(this.musicPartManager.MusicSheet.SheetEndTimestamp);
|
|
}
|
|
}
|
|
|
|
|