|
@@ -413,6 +413,10 @@ class Metronome {
|
|
|
metronomeData.firstBeatTypeArr = beatTypeArr
|
|
|
}
|
|
|
metroMeasure[i] = [] as number[];
|
|
|
+ // 根据有几个拍子,划分成几份
|
|
|
+ const widthStep = 100 / beatTypeArr.length;
|
|
|
+ // 当前拍子的组合数(2+3+2,3+2)中的数字
|
|
|
+ let beatNum = 0;
|
|
|
for (let j = 0; j < beatTypeArr.length; j++) {
|
|
|
// 累加
|
|
|
const beatMuit = Array(j).fill("").reduce((num:number,v:any,i:number) => {
|
|
@@ -420,13 +424,30 @@ class Metronome {
|
|
|
}, 0) || 0
|
|
|
const time = measure.time * beatMuit + measure.start;
|
|
|
metroList.push(time);
|
|
|
+ let left = "";
|
|
|
+ // 当前拍子数对应的节拍位置索引
|
|
|
+ let currentIdx = 0;
|
|
|
+ if (j == 0) {
|
|
|
+ currentIdx = 0
|
|
|
+ } else {
|
|
|
+ beatNum += Number(measure.CompoundTempo.split('+')[j]);
|
|
|
+ currentIdx = beatNum
|
|
|
+ }
|
|
|
+ if (measure.stepList[currentIdx]) {
|
|
|
+ left = measure.stepList[currentIdx] + "px";
|
|
|
+ } else {
|
|
|
+ const preLeft = measure.stepList[j - 1];
|
|
|
+ left = !preLeft ? `${widthStep*(j+1)}%` : preLeft.toString().indexOf("%") > -1 ? `${preLeft} + ${widthStep*(j+1)}%` : `${preLeft}px + ${widthStep*(j+1)}%`;
|
|
|
+ measure.stepList[j] = left;
|
|
|
+ }
|
|
|
metroMeasure[i].push({
|
|
|
isTick: beatTypeArr[j] < 0,
|
|
|
index: j,
|
|
|
time,
|
|
|
- left: 0,
|
|
|
+ left: left?.indexOf("%") > -1 ? `calc(${left})` : left,
|
|
|
measureNumberXML: measure.measureNumberXML,
|
|
|
isRestFlag: measure.isRestFlag,
|
|
|
+ stepList: measure.stepList
|
|
|
});
|
|
|
}
|
|
|
}
|