瀏覽代碼

fix some notes being skipped (not played) during playback (#47)

fix #47
sschmidTU 3 年之前
父節點
當前提交
7cbb43aadc
共有 2 個文件被更改,包括 6 次插入1 次删除
  1. 4 0
      src/MusicalScore/Graphical/EngravingRules.ts
  2. 2 1
      src/MusicalScore/Playback/VoicePlaybackData.ts

+ 4 - 0
src/MusicalScore/Graphical/EngravingRules.ts

@@ -329,6 +329,10 @@ export class EngravingRules {
 
     // Playback
     public PlayAlreadyStartedNotesFromCursorPosition: boolean = false;
+    /** The interval between current timer position and note timestamp beyond which notes are not played.
+     * If you experience notes being skipped during playback, try increasing this interval slightly (e.g. 0.02 -> 0.03).
+     */
+    public PlaybackSkipNotesSafetyInterval: number = 0.02;
 
     constructor() {
         this.loadDefaultValues();

+ 2 - 1
src/MusicalScore/Playback/VoicePlaybackData.ts

@@ -97,7 +97,8 @@ export class VoicePlaybackData {
             maxEntryTimestamp.Add(entry.playbackEntry.Notes[0].Length);
             if (entry.enrolledTimestamp.lt(enrolledTimestamp)) {
                 if (!this.rules.PlayAlreadyStartedNotesFromCursorPosition) {
-                    if (Math.abs(entry.enrolledTimestamp.RealValue - enrolledTimestamp.RealValue) > 0.01) {
+                    const safetyInterval: number = this.rules.PlaybackSkipNotesSafetyInterval; // usually 0.02
+                    if (Math.abs(entry.enrolledTimestamp.RealValue - enrolledTimestamp.RealValue) > safetyInterval) {
                         continue; // don't play notes that started before current cursor position
                         // note that we'd ideally check entry < enrolled, but enrolled is imprecise,
                         //   so e.g. if you start at a timestamp 5.5, enrolled will be ~5.5019