|
|
@@ -201,6 +201,32 @@ export function getGradualLengthByXml(xml: string) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // D.C./D.S. 在本小节结束后跳转,以下一小节起点作为渐变区间的结束边界。
|
|
|
+ // 标记可能位于最后一个音符之后,不能依赖 getNextNote 查找边界。
|
|
|
+ let noteIndex = 0
|
|
|
+ measures.forEach((measure, measureIndex) => {
|
|
|
+ noteIndex += measure.querySelectorAll('note').length
|
|
|
+ const jump = Array.from(measure.querySelectorAll('sound, words')).find((ele) => {
|
|
|
+ if (ele.tagName === 'sound') {
|
|
|
+ return ele.getAttribute('dacapo') === 'yes' || !!ele.getAttribute('dalsegno')?.trim()
|
|
|
+ }
|
|
|
+ const text = ele.textContent?.replace(/[.\s]/g, '').toLocaleLowerCase() || ''
|
|
|
+ return /^(dc|ds|dacapo|dalsegno)(al(coda|fine))?$/.test(text)
|
|
|
+ })
|
|
|
+ if (jump) {
|
|
|
+ eles.push({
|
|
|
+ ele: jump,
|
|
|
+ index: noteIndex,
|
|
|
+ noteInMeasureIndex: 0,
|
|
|
+ textContent: '',
|
|
|
+ type: 'jump',
|
|
|
+ allDuration: 1,
|
|
|
+ leftDuration: 0,
|
|
|
+ measureIndex: measureIndex + 1
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
// 结尾处手动插入一个音符节点
|
|
|
eles.push({
|
|
|
ele: notes[notes.length - 1],
|
|
|
@@ -214,7 +240,8 @@ export function getGradualLengthByXml(xml: string) {
|
|
|
})
|
|
|
|
|
|
const gradualNotes: any[] = []
|
|
|
- eles.sort((a, b) => a.index - b.index)
|
|
|
+ // 同一位置先结束上一段,再处理下一小节新开始的渐变。
|
|
|
+ eles.sort((a, b) => a.index - b.index || Number(b.type === 'jump') - Number(a.type === 'jump'))
|
|
|
const keys = Object.keys(speedInfo).map((w) => w.toLocaleLowerCase())
|
|
|
let isLastNoteAndNotClosed = false
|
|
|
for (const ele of eles) {
|
|
|
@@ -232,6 +259,7 @@ export function getGradualLengthByXml(xml: string) {
|
|
|
return textContent && ks.includes(textContent) || k === textContent
|
|
|
})
|
|
|
if (
|
|
|
+ ele.type === 'jump' ||
|
|
|
ele.type === 'metronome' ||
|
|
|
(ele.type === 'words' && (textContent.startsWith('a tempo') || isKeyWork)) ||
|
|
|
isLastNoteAndNotClosed
|
|
|
@@ -2421,7 +2449,7 @@ export default defineComponent({
|
|
|
{!!gradualData.list.length && (
|
|
|
<>
|
|
|
<NAlert showIcon={false} type="info">
|
|
|
- 识别到共1处渐变速度,请输入Dorico对应小节时间信息
|
|
|
+ 识别到共{gradualData.list.length}处渐变速度,请输入Dorico对应小节时间信息
|
|
|
</NAlert>
|
|
|
<NFormItem label="rit." required style={{ marginTop: '10px' }}>
|
|
|
<NSpace vertical>
|