|
@@ -50,6 +50,7 @@ import TheSetting from "./component/the-setting";
|
|
|
import { useRoute } from "vue-router";
|
|
|
import { api_musicSheetCreationDetail, api_musicSheetCreationUpdate } from "../api";
|
|
|
import instrumentsNames from "/src/constant/instrmentsNames.json";
|
|
|
+import { ALL_NOTES, NOTE_DOT } from "./noteData";
|
|
|
|
|
|
const allPitches = [
|
|
|
"C,,,,",
|
|
@@ -295,6 +296,7 @@ export default defineComponent({
|
|
|
midiBuffer: null as unknown as ABCJS.MidiBuffer,
|
|
|
abcOptions: {
|
|
|
selectionColor: "#0f81ff",
|
|
|
+ jazzchords: true,
|
|
|
add_classes: true,
|
|
|
clickListener: clickListener,
|
|
|
responsive: "resize",
|
|
@@ -411,14 +413,24 @@ export default defineComponent({
|
|
|
},
|
|
|
};
|
|
|
|
|
|
- const resetMidi = (useActive = false) => {
|
|
|
+ const staffNotes = ALL_NOTES();
|
|
|
+ const loadMiniMp3 = async () => {
|
|
|
data.loadingAudioSrouce = true;
|
|
|
const midiBuffer = new ABCJS.synth.CreateSynth();
|
|
|
- // console.log(midiBuffer);
|
|
|
+ const str = `X: 1\nM:4/4\nL:1/4\n${staffNotes}`;
|
|
|
+ const visualObj = ABCJS.parseOnly(str);
|
|
|
+ await midiBuffer.init({
|
|
|
+ visualObj: visualObj[0],
|
|
|
+ options: { ...abcData.synthOptions },
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ const resetMidi = (useActive = false) => {
|
|
|
+ const midiBuffer = new ABCJS.synth.CreateSynth();
|
|
|
midiBuffer
|
|
|
.init({
|
|
|
visualObj: abcData.visualObj,
|
|
|
- options: { ...abcData.synthOptions, midiTranspose: abcData.abc.visualTranspose },
|
|
|
+ options: { ...abcData.synthOptions },
|
|
|
})
|
|
|
.then(() => {
|
|
|
abcData.synthControl
|
|
@@ -873,7 +885,8 @@ export default defineComponent({
|
|
|
const activeNote =
|
|
|
abcData.abc.measures[data.active.measureIndex]?.notes[data.active.noteIndex] || null;
|
|
|
if (!activeNote) return;
|
|
|
- activeNote.dot = activeNote.dot ? "" : value;
|
|
|
+ activeNote.dot = activeNote.dot ? "" : NOTE_DOT[activeNote.noteType];
|
|
|
+ console.log("🚀 ~ activeNote:", activeNote)
|
|
|
await handleResetRender();
|
|
|
rangeHighlight(data.active.startChar);
|
|
|
}
|
|
@@ -1024,7 +1037,6 @@ export default defineComponent({
|
|
|
await handleResetRender();
|
|
|
const _abcElem = rangeHighlight(data.active.startChar);
|
|
|
if (!_abcElem?.midiPitches) return;
|
|
|
- console.log(_abcElem, abcData.visualObj.millisecondsPerMeasure());
|
|
|
ABCJS.synth.playEvent(_abcElem.midiPitches, _abcElem.midiGraceNotePitches, 1000);
|
|
|
};
|
|
|
|
|
@@ -1079,7 +1091,7 @@ export default defineComponent({
|
|
|
const _instruments = ABCJS.synth.instrumentIndexToName.indexOf(abcData.abc.subjectCode as any);
|
|
|
abcData.synthOptions.program = _instruments > -1 ? _instruments : 0;
|
|
|
abcData.abc.measures = abc.measures || initMusic(30);
|
|
|
- console.log("🚀 ~ abcData.abc:", abcData.abc);
|
|
|
+ // console.log("🚀 ~ abcData.abc:", abcData.abc);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -1097,8 +1109,10 @@ export default defineComponent({
|
|
|
};
|
|
|
onMounted(async () => {
|
|
|
await getDetailData();
|
|
|
+ loadMiniMp3();
|
|
|
if (ABCJS.synth.supportsAudio()) {
|
|
|
abcData.synthControl = new ABCJS.synth.SynthController();
|
|
|
+ // console.log("🚀 ~ abcData.synthControl:", abcData.synthControl)
|
|
|
abcData.synthControl.load("#audio", cursorControl, {
|
|
|
displayLoop: true,
|
|
|
displayRestart: true,
|
|
@@ -1116,8 +1130,8 @@ export default defineComponent({
|
|
|
e.returnValue = "还有没保存的";
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
- formateAbc(abcData.visualObj);
|
|
|
+ abcData.synthControl.restart();
|
|
|
+ // formateAbc(abcData.visualObj);
|
|
|
});
|
|
|
onUnmounted(() => {
|
|
|
document.removeEventListener("keyup", handleKeyUp);
|
|
@@ -1474,9 +1488,10 @@ export default defineComponent({
|
|
|
filterable
|
|
|
options={instruments.value}
|
|
|
v-model:value={abcData.synthOptions.program}
|
|
|
- onUpdate:value={() => {
|
|
|
+ onUpdate:value={async () => {
|
|
|
abcData.synthControl.disable(true);
|
|
|
data.playState = false;
|
|
|
+ await loadMiniMp3();
|
|
|
resetMidi(true);
|
|
|
popup.selectSubjectShow = false;
|
|
|
}}
|
|
@@ -2044,18 +2059,7 @@ export default defineComponent({
|
|
|
<div id="paper"></div>
|
|
|
<Keys show={data.active ? true : false} onClick={(val) => handleChange(val)} />
|
|
|
|
|
|
- {/* <div>
|
|
|
- <textarea
|
|
|
- ref={textAreaRef}
|
|
|
- class={styles.value}
|
|
|
- id="abc"
|
|
|
- onChange={() => {
|
|
|
- console.log(textAreaRef.value.value);
|
|
|
- data.music = textAreaRef.value.value;
|
|
|
- handleResetRender();
|
|
|
- }}
|
|
|
- ></textarea>
|
|
|
- </div> */}
|
|
|
+ {/* <textarea ref={textAreaRef} class={styles.value} id="abc"></textarea> */}
|
|
|
<div id="audio" style={{ opacity: 0 }}></div>
|
|
|
<div id="warnings"></div>
|
|
|
|