|
@@ -1260,7 +1260,27 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
|
|
|
*/
|
|
|
if (state.isEvxml && note.isRestFlag && note?.noteTimeInfo?.length === 0 && state.xmlHasTimes ) {
|
|
|
const idx = _notes.findIndex(item=>item.note === note);
|
|
|
- const allowRange = Math.abs(_notes[idx+1]?.note?.noteTimeInfo?.[0]?.begin*1000 - _notes[idx-1]?.note?.noteTimeInfo?.[0]?.end*1000) < 10;
|
|
|
+ let nextNoteTimes = _notes[idx+1]?.note?.noteTimeInfo?.[0]?.begin*1000
|
|
|
+ let preNoteTImes = _notes[idx-1]?.note?.noteTimeInfo?.[0]?.end*1000
|
|
|
+ // 当下一个音符也没有时间的时候,再往下一个找
|
|
|
+ if(!nextNoteTimes && nextNoteTimes!==0){
|
|
|
+ let nextIndex = idx + 2
|
|
|
+ while(!nextNoteTimes && nextIndex<_notes.length){
|
|
|
+ nextNoteTimes = _notes[nextIndex]?.note?.noteTimeInfo?.[0]?.begin*1000
|
|
|
+ nextIndex ++
|
|
|
+ }
|
|
|
+ // 当最后音符就是没有打时间的休止小节,可能nextNoteTimes时间找不到,目前没有处理
|
|
|
+ }
|
|
|
+ if(!preNoteTImes && preNoteTImes!==0){
|
|
|
+ let preIndex = idx - 2
|
|
|
+ while(!preNoteTImes && preIndex>-1){
|
|
|
+ preNoteTImes = _notes[preIndex]?.note?.noteTimeInfo?.[0]?.end*1000
|
|
|
+ preIndex --
|
|
|
+ }
|
|
|
+ // 当没有找到preNoteTImes的时候 赋值为0 (当第一个音符就是没有打时间的休止小节会出现这种情况)
|
|
|
+ preNoteTImes || (preNoteTImes = 0)
|
|
|
+ }
|
|
|
+ const allowRange = Math.abs(nextNoteTimes - preNoteTImes)< 10;
|
|
|
if (allowRange) {
|
|
|
note.maxNoteNum = note.maxNoteNum - 1;
|
|
|
// 唱名时间补齐,当删除这个音符的时候,上个音符的持续时间要加上这个音符的时间
|