Browse Source

fix: 弱起补充时值计算规则修改

TIANYONG 1 year ago
parent
commit
a3f230c10e
1 changed files with 9 additions and 5 deletions
  1. 9 5
      src/pages/detail/helpers.ts

+ 9 - 5
src/pages/detail/helpers.ts

@@ -465,6 +465,7 @@ export const getAllNodes = (osmd: any) => {
           // console.log(iterator.currentMeasure)
           // 如果是弱起就补齐缺省的时长
           if (i === 0) {
+            const diff = getMeasureDurationDiff(iterator.currentMeasure);
             let _firstMeasureRealValue = 0
             const staffEntries = note.sourceMeasure.verticalMeasureList?.[0]?.staffEntries || []
             //计算第一个小节里面的音符时值是否等于整个小节的时值
@@ -473,10 +474,13 @@ export const getAllNodes = (osmd: any) => {
                 _firstMeasureRealValue += _a.sourceStaffEntry.voiceEntries[0].notes[0].length.realValue
               }
             })
-            if (_firstMeasureRealValue < vRealValue){
-              // console.log(_firstMeasureRealValue, vRealValue)
-              // 如果是弱起,将整个小节的时值减去音符的时值,就是缺省的时值
-              difftime = measureLength - noteLength
+            // if (_firstMeasureRealValue < vRealValue){
+            //   // console.log(_firstMeasureRealValue, vRealValue)
+            //   // 如果是弱起,将整个小节的时值减去音符的时值,就是缺省的时值
+            //   difftime = measureLength - noteLength
+            // }
+            if (diff > 0) {
+              difftime = diff * formatBeatUnit(beatUnit) * (60 / beatSpeed);
             }
             /** 如果是酷乐秀MIDI类型文件就不处理弱起 */
             if (state.activeDetail?.audioType === 'MIDI') {
@@ -484,7 +488,7 @@ export const getAllNodes = (osmd: any) => {
             }
             fixtime += difftime
           }
-          //console.log('👀看看endtime', relaEndtime, fixtime, i)
+          // console.log('👀看看endtime', relaEndtime, fixtime, i)
           const _noteLength = noteRealValue
           const nodeDetail = {
             _noteLength,