Sfoglia il codice sorgente

fix: 部分包含附点音符时值计算问题修复

TIANYONG 9 mesi fa
parent
commit
cf4d7bca0f

+ 14 - 2
osmd-extended/src/MusicalScore/ScoreIO/VoiceGenerator.ts

@@ -526,9 +526,16 @@ export class VoiceGenerator {
                          stringNumber, fretNumber, bends);
     }
 
+    // 添加音符是否有附点信息
+    let isDotNote = false;
+    const noteDotDom: IXmlElement = node?.element("dot");
+    if (noteDotDom) {
+      isDotNote = true;
+    }
+
     this.addNoteInfo(note, noteTypeXml, printObject, isCueNote, normalNotes,
                      displayStepUnpitched, displayOctaveUnpitched,
-                     noteheadColorXml, noteheadColorXml);
+                     noteheadColorXml, noteheadColorXml, isDotNote);
     note.TypeLength = typeDuration;
     note.IsGraceNote = isGraceNote;
     note.StemDirectionXml = stemDirectionXml; // maybe unnecessary, also in VoiceEntry
@@ -590,7 +597,7 @@ export class VoiceGenerator {
   // common for "normal" notes and rest notes
   private addNoteInfo(note: Note, noteTypeXml: NoteType, printObject: boolean, isCueNote: boolean, normalNotes: number,
                       displayStep: NoteEnum, displayOctave: number,
-                      noteheadColorXml: string, noteheadColor: string): void {
+                      noteheadColorXml: string, noteheadColor: string, isDotNote?: boolean): void {
       // common for normal notes and rest note
       note.NoteTypeXml = noteTypeXml;
       note.PrintObject = printObject;
@@ -603,6 +610,11 @@ export class VoiceGenerator {
       // add TypeLength for rest notes like with Note?
       // add IsGraceNote for rest notes like with Notes?
       // add PlaybackInstrumentId for rest notes?
+      // 是否有附点
+      if (isDotNote) {
+        note.isDotNote = isDotNote
+      }
+      
     }
 
   /**

+ 2 - 0
osmd-extended/src/MusicalScore/VoiceData/Note.ts

@@ -117,6 +117,8 @@ export class Note {
      */
     public NoteToGraphicalNoteObjectId: number; // used with EngravingRules.NoteToGraphicalNoteMap
 
+    public isDotNote: boolean; // 添加是否是附点音符字段
+
     public get TremoloType(): string {
         return this.noteTremoloType
     }

+ 11 - 3
src/pages/detail/helpers.ts

@@ -445,9 +445,17 @@ export const getAllNodes = (osmd: any) => {
           //   noteLength = measureLength
           // }
           // 处理附点时长不正确问题
-          if (note.DotsXml && note.tuplet) {
-            console.log('处理附点时长不正确问题')
-            noteLength = noteLength * 1.5
+          // console.log(i,note.DotsXml,note.tuplet,note.isDotNote,note)
+          // if (note.DotsXml && note.tuplet) {
+          //   console.log('处理附点时长不正确问题')
+          //   noteLength = noteLength * 1.5
+          // }
+          // 处理附点时长不正确问题
+          if (note.DotsXml && note.isDotNote) {
+            if (note?.typeLength?.realValue === note?.length?.realValue) {
+              // console.log(i,'处理附点时长不正确问题',note.tuplet)
+              noteLength = noteLength * 1.5
+            }
           }
           // 后倚音通过跳过的方式实现
           if (skipNextNote) {

+ 1 - 1
vite.config.js

@@ -5,7 +5,7 @@ import glsl from 'vite-plugin-glsl'
 const vueJsx = require('@vitejs/plugin-vue-jsx')
 const legacy = require('@vitejs/plugin-legacy')
 
-const proxyUrl = 'https://test.lexiaoya.cn/' // test 环境
+const proxyUrl = 'https://online.lexiaoya.cn/' // test 环境
 // const proxyUrl = 'http://192.168.3.70:8989/' // test 环境
 // const proxyUrl = 'https://online.colexiu.com/' // online 环境