|
@@ -140,8 +140,8 @@ export const getAllNodes = (osmd: any) => {
|
|
|
|
|
|
|
|
|
const cursorImg: HTMLElement = osmd.cursor.cursorElement
|
|
|
- const cursorBox: any = {move: false}
|
|
|
- if (cursorImg){
|
|
|
+ const cursorBox: any = { move: false }
|
|
|
+ if (cursorImg) {
|
|
|
cursorBox.move = true
|
|
|
cursorBox.x = cursorImg.offsetLeft
|
|
|
cursorBox.y = cursorImg.offsetTop
|
|
@@ -214,17 +214,23 @@ export const getAllNodes = (osmd: any) => {
|
|
|
(state.isSpecialBookCategory
|
|
|
? getTimeByBeatUnit(beatUnit, measureSpeed, iterator.currentMeasure.activeTimeSignature.Denominator)
|
|
|
: baseSpeed) || 1
|
|
|
-
|
|
|
let speed = (state.isSpecialBookCategory ? measureSpeed : baseSpeed) || 1
|
|
|
+ console.log('曲谱设置的速度', { isTeshu:state.isSpecialBookCategory, beatSpeed, speed})
|
|
|
if (i === 0) {
|
|
|
fixtime += getFixTime(beatSpeed)
|
|
|
}
|
|
|
- let noteLength = (numerator === 0 && note.isRestFlag ? vRealValue : (wholeValue + numerator) / denominator) * vDenominator * (60 / beatSpeed)
|
|
|
+ let noteLength =
|
|
|
+ (numerator === 0 && note.isRestFlag ? vRealValue : (wholeValue + numerator) / denominator) *
|
|
|
+ vDenominator *
|
|
|
+ (60 / beatSpeed)
|
|
|
const measureLength = vRealValue * vDenominator * (60 / beatSpeed)
|
|
|
|
|
|
if (['Piano'].includes(state.activeDetail?.code)) {
|
|
|
const currentRealValue = iterator.currentTimeStamp.realValue - currentRealValueTotal
|
|
|
- noteLength = (currentRealValue || (numerator === 0 ? vRealValue : (wholeValue + numerator) / denominator)) * vDenominator * (60 / beatSpeed)
|
|
|
+ noteLength =
|
|
|
+ (currentRealValue || (numerator === 0 ? vRealValue : (wholeValue + numerator) / denominator)) *
|
|
|
+ vDenominator *
|
|
|
+ (60 / beatSpeed)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -237,11 +243,11 @@ export const getAllNodes = (osmd: any) => {
|
|
|
}
|
|
|
|
|
|
|
|
|
- if(note.isRestFlag && noteLength > measureLength){
|
|
|
+ if (note.isRestFlag && noteLength > measureLength) {
|
|
|
noteLength = measureLength
|
|
|
}
|
|
|
|
|
|
- if (note.DotsXml && (note.tuplet)) {
|
|
|
+ if (note.DotsXml && note.tuplet) {
|
|
|
noteLength = noteLength * 1.5
|
|
|
}
|
|
|
|
|
@@ -319,16 +325,18 @@ export const getAllNodes = (osmd: any) => {
|
|
|
halfTone: note.halfTone,
|
|
|
voiceEntry: {
|
|
|
isStaccato: note.voiceEntry.isStaccato(),
|
|
|
- Timestamp: {...note.voiceEntry.Timestamp},
|
|
|
- ornamentContainer: note.voiceEntry.ornamentContainer ? {...note.voiceEntry.ornamentContainer} : ''
|
|
|
+ Timestamp: { ...note.voiceEntry.Timestamp },
|
|
|
+ ornamentContainer: note.voiceEntry.ornamentContainer ? { ...note.voiceEntry.ornamentContainer } : '',
|
|
|
},
|
|
|
noteElement: {
|
|
|
NoteToGraphicalNoteObjectId: note.NoteToGraphicalNoteObjectId,
|
|
|
- notehead: note.notehead ? {
|
|
|
- filled: note.notehead.filled,
|
|
|
- shape: note.notehead.shape,
|
|
|
- sourceNote: note.notehead.sourceNote?.NoteToGraphicalNoteObjectId,
|
|
|
- } : '',
|
|
|
+ notehead: note.notehead
|
|
|
+ ? {
|
|
|
+ filled: note.notehead.filled,
|
|
|
+ shape: note.notehead.shape,
|
|
|
+ sourceNote: note.notehead.sourceNote?.NoteToGraphicalNoteObjectId,
|
|
|
+ }
|
|
|
+ : '',
|
|
|
noteheadColor: note.noteheadColor,
|
|
|
isRestFlag: note.isRestFlag,
|
|
|
sourceMeasure: {
|
|
@@ -337,63 +345,86 @@ export const getAllNodes = (osmd: any) => {
|
|
|
allRests: note?.SourceMeasure?.allRests,
|
|
|
isRestFlag: note?.SourceMeasure?.isRestFlag,
|
|
|
multipleRestMeasures: note?.SourceMeasure?.multipleRestMeasures,
|
|
|
- verticalMeasureList: Array.isArray(note?.SourceMeasure?.verticalMeasureList) ? note.SourceMeasure.verticalMeasureList.map((v: any) => {
|
|
|
- const {x, y, width, height, start_x, end_x} = v?.stave || {}
|
|
|
- return v ? {
|
|
|
- stave: {
|
|
|
- x, y, width, height, start_x, end_x
|
|
|
- },
|
|
|
- boundingBox: v && v.boundingBox ? {
|
|
|
- absolutePosition: {...v.boundingBox.absolutePosition},
|
|
|
- size: {...v.boundingBox.size}
|
|
|
- } : ''
|
|
|
- } : undefined
|
|
|
- }) : [],
|
|
|
- activeTimeSignature: {...note.activeTimeSignature},
|
|
|
+ verticalMeasureList: Array.isArray(note?.SourceMeasure?.verticalMeasureList)
|
|
|
+ ? note.SourceMeasure.verticalMeasureList.map((v: any) => {
|
|
|
+ const { x, y, width, height, start_x, end_x } = v?.stave || {}
|
|
|
+ return v
|
|
|
+ ? {
|
|
|
+ stave: {
|
|
|
+ x,
|
|
|
+ y,
|
|
|
+ width,
|
|
|
+ height,
|
|
|
+ start_x,
|
|
|
+ end_x,
|
|
|
+ },
|
|
|
+ boundingBox:
|
|
|
+ v && v.boundingBox
|
|
|
+ ? {
|
|
|
+ absolutePosition: { ...v.boundingBox.absolutePosition },
|
|
|
+ size: { ...v.boundingBox.size },
|
|
|
+ }
|
|
|
+ : '',
|
|
|
+ }
|
|
|
+ : undefined
|
|
|
+ })
|
|
|
+ : [],
|
|
|
+ activeTimeSignature: { ...note.activeTimeSignature },
|
|
|
},
|
|
|
- tie: note.tie ? {
|
|
|
- StartNote: {
|
|
|
- NoteToGraphicalNoteObjectId: note.tie.StartNote.NoteToGraphicalNoteObjectId
|
|
|
- },
|
|
|
- notes: Array.isArray(note.tie.notes) && note.tie.notes?.map((_tie: any) => {
|
|
|
- return {
|
|
|
- NoteToGraphicalNoteObjectId: _tie.NoteToGraphicalNoteObjectId
|
|
|
- }
|
|
|
- }) || []
|
|
|
- } : '',
|
|
|
- slurs: Array.isArray(note.slurs) ? note.slurs.map((slur: any) => {
|
|
|
- return {
|
|
|
- startNote: {
|
|
|
- NoteToGraphicalNoteObjectId: slur.startNote.NoteToGraphicalNoteObjectId
|
|
|
- },
|
|
|
- endNote: {
|
|
|
- NoteToGraphicalNoteObjectId: slur.endNote.NoteToGraphicalNoteObjectId
|
|
|
+ tie: note.tie
|
|
|
+ ? {
|
|
|
+ StartNote: {
|
|
|
+ NoteToGraphicalNoteObjectId: note.tie.StartNote.NoteToGraphicalNoteObjectId,
|
|
|
+ },
|
|
|
+ notes:
|
|
|
+ (Array.isArray(note.tie.notes) &&
|
|
|
+ note.tie.notes?.map((_tie: any) => {
|
|
|
+ return {
|
|
|
+ NoteToGraphicalNoteObjectId: _tie.NoteToGraphicalNoteObjectId,
|
|
|
+ }
|
|
|
+ })) ||
|
|
|
+ [],
|
|
|
}
|
|
|
- }
|
|
|
- }) : [],
|
|
|
+ : '',
|
|
|
+ slurs: Array.isArray(note.slurs)
|
|
|
+ ? note.slurs.map((slur: any) => {
|
|
|
+ return {
|
|
|
+ startNote: {
|
|
|
+ NoteToGraphicalNoteObjectId: slur.startNote.NoteToGraphicalNoteObjectId,
|
|
|
+ },
|
|
|
+ endNote: {
|
|
|
+ NoteToGraphicalNoteObjectId: slur.endNote.NoteToGraphicalNoteObjectId,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ })
|
|
|
+ : [],
|
|
|
pitch: {
|
|
|
prevFrequency: note.pitch?.prevFrequency,
|
|
|
nextFrequency: note.pitch?.nextFrequency,
|
|
|
- frequency: note.pitch?.frequency
|
|
|
+ frequency: note.pitch?.frequency,
|
|
|
},
|
|
|
Length: {
|
|
|
- ...note.Length
|
|
|
- }
|
|
|
+ ...note.Length,
|
|
|
+ },
|
|
|
},
|
|
|
- svgElelent: svgElelent ? {
|
|
|
- bbox: svgElelent.getBoundingBox?.() || '',
|
|
|
- top_y: svgElelent.top_y,
|
|
|
- note_height: svgElelent.note_height,
|
|
|
- } : '',
|
|
|
+ svgElelent: svgElelent
|
|
|
+ ? {
|
|
|
+ bbox: svgElelent.getBoundingBox?.() || '',
|
|
|
+ top_y: svgElelent.top_y,
|
|
|
+ note_height: svgElelent.note_height,
|
|
|
+ }
|
|
|
+ : '',
|
|
|
fixedKey,
|
|
|
realKey: 0,
|
|
|
duration: 0,
|
|
|
formatLyricsEntries: formatLyricsEntries(note),
|
|
|
- stave: activeVerticalMeasureList[0] && activeVerticalMeasureList[0].stave ? {
|
|
|
- attrs: activeVerticalMeasureList[0].stave ? {...activeVerticalMeasureList[0].stave.attrs} : {},
|
|
|
-
|
|
|
- } : '' ,
|
|
|
- firstVerticalMeasure: {measureNumber: activeVerticalMeasureList?.[0]?.measureNumber } ,
|
|
|
+ stave:
|
|
|
+ activeVerticalMeasureList[0] && activeVerticalMeasureList[0].stave
|
|
|
+ ? {
|
|
|
+ attrs: activeVerticalMeasureList[0].stave ? { ...activeVerticalMeasureList[0].stave.attrs } : {},
|
|
|
+ }
|
|
|
+ : '',
|
|
|
+ firstVerticalMeasure: { measureNumber: activeVerticalMeasureList?.[0]?.measureNumber },
|
|
|
noteLength: 1,
|
|
|
halfTone1: Array.isArray(v.notes) ? v.notes.map((n: any) => n.halfTone + 12).filter(Boolean) : [],
|
|
|
halfTone2:
|
|
@@ -410,7 +441,7 @@ export const getAllNodes = (osmd: any) => {
|
|
|
allNoteId.push(nodeDetail.id)
|
|
|
measures.push({
|
|
|
realKey: nodeDetail.realKey,
|
|
|
- NoteToGraphicalNoteObjectId: note.NoteToGraphicalNoteObjectId
|
|
|
+ NoteToGraphicalNoteObjectId: note.NoteToGraphicalNoteObjectId,
|
|
|
})
|
|
|
if (si < sublength - 1) {
|
|
|
si++
|
|
@@ -419,7 +450,6 @@ export const getAllNodes = (osmd: any) => {
|
|
|
relaMeasureLength = 0
|
|
|
measures = []
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -438,7 +468,7 @@ export const getAllNodes = (osmd: any) => {
|
|
|
const note = { ...sortArray[i] }
|
|
|
const prevNote = sortArray[i - 1]
|
|
|
const isNotNeedStop = note.noteElement.tie && prevNote?.noteElement.tie && note.halfTone === prevNote?.halfTone
|
|
|
- const isOvertone = false
|
|
|
+ const isOvertone = false
|
|
|
if (prevNote) {
|
|
|
if (isNotNeedStop || isOvertone) {
|
|
|
note.sourceStartTime = note.time
|
|
@@ -484,20 +514,19 @@ export const getAllNoteElements = (osmd: any) => {
|
|
|
}
|
|
|
|
|
|
export const setStepIndex = (osmd: any, num: number, prev?: number) => {
|
|
|
- if(osmd.product){
|
|
|
- if(num || num === 0){
|
|
|
+ if (osmd.product) {
|
|
|
+ if (num || num === 0) {
|
|
|
|
|
|
if (prev && num - prev === 1) {
|
|
|
- osmd.cursor.setPosition({...state.times[num].cursorBox})
|
|
|
+ osmd.cursor.setPosition({ ...state.times[num].cursorBox })
|
|
|
} else if (prev && num - prev > 0) {
|
|
|
while (num - prev > 0) {
|
|
|
prev++
|
|
|
- osmd.cursor.setPosition({...state.times[prev].cursorBox})
|
|
|
+ osmd.cursor.setPosition({ ...state.times[prev].cursorBox })
|
|
|
}
|
|
|
} else {
|
|
|
- osmd.cursor.setPosition({...state.times[num].cursorBox})
|
|
|
+ osmd.cursor.setPosition({ ...state.times[num].cursorBox })
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
} else {
|
|
|
if (num || num === 0) {
|
|
@@ -525,7 +554,6 @@ export const setStepIndex = (osmd: any, num: number, prev?: number) => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
export const getIndex = (times: any[], currentTime: Number) => {
|