|
@@ -163,6 +163,7 @@ export default defineComponent({
|
|
loadingAudioSrouce: false, // 加载音频资源
|
|
loadingAudioSrouce: false, // 加载音频资源
|
|
/** 移调类型 */
|
|
/** 移调类型 */
|
|
moveKeyType: "inset" as "inset" | "up" | "down", // 移调类型
|
|
moveKeyType: "inset" as "inset" | "up" | "down", // 移调类型
|
|
|
|
+ activePlayNote: null as any, // 当前演奏音符
|
|
});
|
|
});
|
|
const noteTypes = ABC_DATA.types.map((item) => item.value).filter(Boolean);
|
|
const noteTypes = ABC_DATA.types.map((item) => item.value).filter(Boolean);
|
|
const accidentals = ABC_DATA.accidentals.map((item) => item.value).filter(Boolean);
|
|
const accidentals = ABC_DATA.accidentals.map((item) => item.value).filter(Boolean);
|
|
@@ -311,7 +312,6 @@ export default defineComponent({
|
|
metronomeData.metro.sound(time);
|
|
metronomeData.metro.sound(time);
|
|
},
|
|
},
|
|
onEvent: (ev: any) => {
|
|
onEvent: (ev: any) => {
|
|
- // console.log("🚀 ~ ev:", ev);
|
|
|
|
if (!data.playState) return;
|
|
if (!data.playState) return;
|
|
if (ev.measureStart && ev.left === null) return; // this was the second part of a tie across a measure line. Just ignore it.
|
|
if (ev.measureStart && ev.left === null) return; // this was the second part of a tie across a measure line. Just ignore it.
|
|
if (popup.selectMearesShow) {
|
|
if (popup.selectMearesShow) {
|
|
@@ -331,6 +331,7 @@ export default defineComponent({
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ data.activePlayNote = {...ev};
|
|
var cursor = document.querySelector("#paper svg .ABCJS-cursor");
|
|
var cursor = document.querySelector("#paper svg .ABCJS-cursor");
|
|
if (cursor) {
|
|
if (cursor) {
|
|
cursor.setAttribute("x1", ev.left + ev.width / 2);
|
|
cursor.setAttribute("x1", ev.left + ev.width / 2);
|
|
@@ -392,10 +393,23 @@ export default defineComponent({
|
|
data.playState = true;
|
|
data.playState = true;
|
|
} else if (type === "pause") {
|
|
} else if (type === "pause") {
|
|
abcData.synthControl.play();
|
|
abcData.synthControl.play();
|
|
|
|
+ // abcData.synthControl.pause();
|
|
data.playState = false;
|
|
data.playState = false;
|
|
hideCursor();
|
|
hideCursor();
|
|
|
|
+ const totalTime = (abcData.synthControl as any).visualObj.getTotalTime();
|
|
|
|
+ if (totalTime && data.activePlayNote?.milliseconds !== undefined) {
|
|
|
|
+ const progress = data.activePlayNote.milliseconds / 1000 / totalTime;
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ (abcData.synthControl as any).seek(progress);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
abcData.synthControl.restart();
|
|
abcData.synthControl.restart();
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ if (!data.playState){
|
|
|
|
+ abcData.synthControl.play();
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
// console.log("🚀 ~ abcData.synthControl:", abcData.synthControl.timer.noteTimings);
|
|
// console.log("🚀 ~ abcData.synthControl:", abcData.synthControl.timer.noteTimings);
|
|
};
|
|
};
|
|
@@ -449,6 +463,14 @@ export default defineComponent({
|
|
data.selectMeasures.max = measureNumber;
|
|
data.selectMeasures.max = measureNumber;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ let saveTimer: any = null;
|
|
|
|
+ const autoSave = () => {
|
|
|
|
+ saveTimer && clearTimeout(saveTimer);
|
|
|
|
+ saveTimer = setTimeout(() => {
|
|
|
|
+ handleSaveMusic(false);
|
|
|
|
+ }, 5000);
|
|
|
|
+ };
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @param isProduct 是否是生成曲谱
|
|
* @param isProduct 是否是生成曲谱
|
|
*/
|
|
*/
|
|
@@ -473,6 +495,11 @@ export default defineComponent({
|
|
}
|
|
}
|
|
|
|
|
|
resolve(1);
|
|
resolve(1);
|
|
|
|
+ if (data.drawCount > 0) {
|
|
|
|
+ const host = location.host;
|
|
|
|
+ if (host.includes("localhost") || host.includes("192")) return;
|
|
|
|
+ autoSave();
|
|
|
|
+ }
|
|
|
|
|
|
textAreaRef.value && (textAreaRef.value.value = data.music);
|
|
textAreaRef.value && (textAreaRef.value.value = data.music);
|
|
data.drawCount++;
|
|
data.drawCount++;
|
|
@@ -512,7 +539,7 @@ export default defineComponent({
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- console.log("abcData.abc.measures", list);
|
|
|
|
|
|
+ // console.log("abcData.abc.measures", list);
|
|
if (!metronomeData.metro) {
|
|
if (!metronomeData.metro) {
|
|
metronomeData.metro = new Metronome();
|
|
metronomeData.metro = new Metronome();
|
|
}
|
|
}
|
|
@@ -1134,7 +1161,7 @@ export default defineComponent({
|
|
|
|
|
|
abcData.abc.celf = abc.celf || "K:treble";
|
|
abcData.abc.celf = abc.celf || "K:treble";
|
|
abcData.abc.key = abc.key.value || abc.key || "K:C";
|
|
abcData.abc.key = abc.key.value || abc.key || "K:C";
|
|
- abcData.abc.meter = abc.meter.value|| abc.meter || "M:4/4";
|
|
|
|
|
|
+ abcData.abc.meter = abc.meter.value || abc.meter || "M:4/4";
|
|
abcData.abc.speed = abc.speed || "Q:1/4=60";
|
|
abcData.abc.speed = abc.speed || "Q:1/4=60";
|
|
abcData.abc.visualTranspose = abc.visualTranspose || 0;
|
|
abcData.abc.visualTranspose = abc.visualTranspose || 0;
|
|
abcData.abc.subjectCode = abc.subjectCode || "acoustic_grand_piano";
|
|
abcData.abc.subjectCode = abc.subjectCode || "acoustic_grand_piano";
|
|
@@ -1184,7 +1211,6 @@ export default defineComponent({
|
|
}
|
|
}
|
|
};
|
|
};
|
|
abcData.synthControl.restart();
|
|
abcData.synthControl.restart();
|
|
- // formateAbc(abcData.visualObj);
|
|
|
|
const selectMearesBtn = document.querySelector("#selectMearesBtn");
|
|
const selectMearesBtn = document.querySelector("#selectMearesBtn");
|
|
if (selectMearesBtn) {
|
|
if (selectMearesBtn) {
|
|
const rect = selectMearesBtn.getBoundingClientRect();
|
|
const rect = selectMearesBtn.getBoundingClientRect();
|
|
@@ -1352,13 +1378,15 @@ export default defineComponent({
|
|
const reader = new FileReader();
|
|
const reader = new FileReader();
|
|
reader.onload = (e: any) => {
|
|
reader.onload = (e: any) => {
|
|
let abc = e.target.result;
|
|
let abc = e.target.result;
|
|
- console.log("🚀 ~ abc:", abc);
|
|
|
|
|
|
+ // console.log("🚀 ~ abc:", abc);
|
|
abc = new DOMParser().parseFromString(abc, "text/xml");
|
|
abc = new DOMParser().parseFromString(abc, "text/xml");
|
|
- console.log("🚀 ~ abc:", abc);
|
|
|
|
|
|
+ // console.log("🚀 ~ abc:", abc);
|
|
abc = (window as any).vertaal(abc, { p: "f", t: 1, u: 0, v: 3, mnum: 0 });
|
|
abc = (window as any).vertaal(abc, { p: "f", t: 1, u: 0, v: 3, mnum: 0 });
|
|
- console.log(abc);
|
|
|
|
- // data.music = abc[0];
|
|
|
|
- // handleResetRender(false);
|
|
|
|
|
|
+ // console.log(abc);
|
|
|
|
+ const parseData = ABCJS.renderAbc("importRef", abc[0], { responsive: "resize" });
|
|
|
|
+ console.log("🚀 ~ parseData:", parseData);
|
|
|
|
+ abcData.abc = formateAbc(parseData[0], { subjectCode: abcData.abc.subjectCode });
|
|
|
|
+ handleResetRender();
|
|
};
|
|
};
|
|
reader.readAsText(file);
|
|
reader.readAsText(file);
|
|
};
|
|
};
|
|
@@ -2226,13 +2254,8 @@ export default defineComponent({
|
|
)}
|
|
)}
|
|
|
|
|
|
{/* <textarea ref={textAreaRef} class={styles.value} id="abc"></textarea> */}
|
|
{/* <textarea ref={textAreaRef} class={styles.value} id="abc"></textarea> */}
|
|
|
|
+ <div id="importRef"></div>
|
|
<div id="audio" style={{ display: "none" }}></div>
|
|
<div id="audio" style={{ display: "none" }}></div>
|
|
- <div id="warnings"></div>
|
|
|
|
-
|
|
|
|
- <p class="beat"></p>
|
|
|
|
- <pre class="clicked-info"></pre>
|
|
|
|
- <pre class="feedback"></pre>
|
|
|
|
- <div id="container"></div>
|
|
|
|
{data.loadingAudioSrouce && (
|
|
{data.loadingAudioSrouce && (
|
|
<div class={styles.loading}>
|
|
<div class={styles.loading}>
|
|
<NSpin></NSpin>
|
|
<NSpin></NSpin>
|