Ver Fonte

feat: 计算小节时长时,过滤掉倚音音符

TIANYONG há 4 meses atrás
pai
commit
8cf17b1e87
2 ficheiros alterados com 6 adições e 4 exclusões
  1. 1 1
      osmd-extended
  2. 5 3
      src/helpers/formateMusic.ts

+ 1 - 1
osmd-extended

@@ -1 +1 @@
-Subproject commit 31363bdaf7a29647b1561e1ac1d01d8be64d4b69
+Subproject commit 46bdba03a3654e74d0ad2bd61e993a2467d0f80e

+ 5 - 3
src/helpers/formateMusic.ts

@@ -1219,9 +1219,11 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 				const staffEntries = note.sourceMeasure.verticalMeasureList?.[0]?.staffEntries || [];
 				//计算第一个小节里面的音符时值是否等于整个小节的时值
 				staffEntries.forEach((_a: any) => {
-					if (_a?.sourceStaffEntry?.voiceEntries?.[0]?.notes?.[0]?.length?.realValue) {
-						_firstMeasureRealValue += _a.sourceStaffEntry.voiceEntries[0].notes[0].length.realValue;
-					}
+					// 需要过滤掉倚音音符
+					const matchNote = _a?.sourceStaffEntry?.voiceEntries?.length > 1 ? _a?.sourceStaffEntry?.voiceEntries.find((item: any) => !item.isGrace) : _a?.sourceStaffEntry?.voiceEntries?.[0]
+					if (matchNote?.notes?.[0]?.length?.realValue) {
+						_firstMeasureRealValue += matchNote.notes[0].length.realValue;
+					}					
 				});
 				if (_firstMeasureRealValue < vRealValue) {
 					// console.log(_firstMeasureRealValue, vRealValue)