|
@@ -22,6 +22,71 @@ export const retain = (time: number) => {
|
|
return Math.ceil(time * 1000000) / 1000000
|
|
return Math.ceil(time * 1000000) / 1000000
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+export function formatBeatUnit(beatUnit: string) {
|
|
|
|
+ let multiple = 4
|
|
|
|
+ switch (beatUnit) {
|
|
|
|
+ case '1024th':
|
|
|
|
+ // bpm = bpm;
|
|
|
|
+ multiple = 1024
|
|
|
|
+ break
|
|
|
|
+ case '512th':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) * 512;
|
|
|
|
+ multiple = 512
|
|
|
|
+ break
|
|
|
|
+ case '256th':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) * 256;
|
|
|
|
+ multiple = 256
|
|
|
|
+ break
|
|
|
|
+ case '128th':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) * 128;
|
|
|
|
+ multiple = 128
|
|
|
|
+ break
|
|
|
|
+ case '64th':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) * 64;
|
|
|
|
+ multiple = 64
|
|
|
|
+ break
|
|
|
|
+ case '32nd':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) * 32;
|
|
|
|
+ multiple = 32
|
|
|
|
+ break
|
|
|
|
+ case '16th':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) * 16;
|
|
|
|
+ multiple = 16
|
|
|
|
+ break
|
|
|
|
+ case 'eighth':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) * 8;
|
|
|
|
+ multiple = 8
|
|
|
|
+ break
|
|
|
|
+ case 'quarter':
|
|
|
|
+ multiple = 4
|
|
|
|
+ break
|
|
|
|
+ case 'half':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) * 2;
|
|
|
|
+ multiple = 2
|
|
|
|
+ break
|
|
|
|
+ case 'whole':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4);
|
|
|
|
+ multiple = 1
|
|
|
|
+ break
|
|
|
|
+ case 'breve':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) / 2;
|
|
|
|
+ multiple = 0.5
|
|
|
|
+ break
|
|
|
|
+ case 'long':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) / 4;
|
|
|
|
+ multiple = 0.25
|
|
|
|
+ break
|
|
|
|
+ case 'maxima':
|
|
|
|
+ // divisionsFromNote = (noteDuration / 4) / 8;
|
|
|
|
+ multiple = 0.125
|
|
|
|
+ break
|
|
|
|
+ default:
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return multiple
|
|
|
|
+}
|
|
|
|
+
|
|
export const formatLyricsEntries = (note: any) => {
|
|
export const formatLyricsEntries = (note: any) => {
|
|
const voiceEntries = note.parentStaffEntry?.voiceEntries || []
|
|
const voiceEntries = note.parentStaffEntry?.voiceEntries || []
|
|
const lyricsEntries: string[] = []
|
|
const lyricsEntries: string[] = []
|
|
@@ -220,10 +285,13 @@ export const getAllNodes = (osmd: any) => {
|
|
fixtime += getFixTime(beatSpeed)
|
|
fixtime += getFixTime(beatSpeed)
|
|
}
|
|
}
|
|
// console.log({fixtime, relativeTime})
|
|
// console.log({fixtime, relativeTime})
|
|
- 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)
|
|
|
|
+ //管乐迷计算时值方法
|
|
|
|
+ let noteLength = Math.min(vRealValue, noteRealValue) * formatBeatUnit(beatUnit) * (60 / beatSpeed)
|
|
const measureLength = vRealValue * vDenominator * (60 / beatSpeed)
|
|
const measureLength = vRealValue * vDenominator * (60 / beatSpeed)
|
|
// 单独处理个别的声部
|
|
// 单独处理个别的声部
|
|
if (['Piano'].includes(state.activeDetail?.code)) {
|
|
if (['Piano'].includes(state.activeDetail?.code)) {
|
|
@@ -271,7 +339,7 @@ export const getAllNodes = (osmd: any) => {
|
|
usetime += noteLength
|
|
usetime += noteLength
|
|
relaMeasureLength += noteLength
|
|
relaMeasureLength += noteLength
|
|
let relaEndtime = noteLength + relativeTime
|
|
let relaEndtime = noteLength + relativeTime
|
|
- console.log({noteLength,relativeTime ,relaEndtime, endtime: relaEndtime + fixtime})
|
|
|
|
|
|
+ // console.log({noteLength,relativeTime ,relaEndtime, endtime: relaEndtime + fixtime})
|
|
const fixedKey = note.ParentVoiceEntry.ParentVoice.Parent.SubInstruments[0].fixedKey || 0
|
|
const fixedKey = note.ParentVoiceEntry.ParentVoice.Parent.SubInstruments[0].fixedKey || 0
|
|
// const svgElelent = activeVerticalMeasureList[0]?.vfVoices['1']?.tickables[si]
|
|
// const svgElelent = activeVerticalMeasureList[0]?.vfVoices['1']?.tickables[si]
|
|
const svgElelent = activeVerticalMeasureList[0]?.vfVoices['1']?.tickables[staveNoteIndex]
|
|
const svgElelent = activeVerticalMeasureList[0]?.vfVoices['1']?.tickables[staveNoteIndex]
|