Browse Source

fix: 小酷AI bug修复

TIANYONG 7 months ago
parent
commit
a8fff10c22

+ 2 - 2
instrument.html

@@ -53,11 +53,11 @@
   </script>
 
   <script type="module" src="/src/page-instrument/main.ts"></script>
-  <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
+  <!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
   <script>
     // VConsole will be exported to `window.VConsole` by default.
     var vConsole = new window.VConsole();
-  </script>  
+  </script>   -->
 </body>
 
 </html>

+ 22 - 1
src/helpers/customMusicScore.ts

@@ -314,6 +314,10 @@ export const resetFormate = () => {
 		for (let i = 0; i < vftexts.length; i++) {
 			const _text = vftexts[i];
 			for (let j = 0; j < vftexts.length; j++) {
+				if (_text.textContent === 'second time only') {
+					// @ts-ignore
+					_text.style.transform = `translateY(15px)`;
+				}
 				if (_text.parentNode === vftexts[j].parentNode) continue;
 				const result = collisionDetection(_text as SVGAElement, vftexts[j] as SVGAElement);
 				if (result.isCollision) {
@@ -570,9 +574,26 @@ export const resetFormate = () => {
 		}
 
 	}
-	
+	if (!state.isCombineRender) {
+		transSinglePage();
+	}
 	// setTimeout(() => this.resetGlobalText());
 };
+
+// 一行谱时,五线谱/简谱的谱面staffLine,居中显示
+const transSinglePage = () => {
+	if (state.isSingleLine) {
+		const svgPage = document?.getElementById('osmdSvgPage1')?.getBoundingClientRect();
+		const staffLine = document?.querySelector('.staffline')?.getBoundingClientRect();
+		if (svgPage && staffLine && svgPage.height > 130) {
+			// 需要上移的距离
+			const needTransTop = (svgPage.height - staffLine.height) / 2;
+			// @ts-ignore
+			document.getElementById('osmdSvgPage1').style.transform = `translateY(-${needTransTop}px)`;
+		}
+	}
+}
+
 // 技巧文本
 const resetGlobalText = () => {
 	const svg = container.value.querySelector("svg");

+ 4 - 1
src/helpers/formateMusic.ts

@@ -1130,7 +1130,10 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 			// console.log('relaEndtime',noteLength, relativeTime)
 			const fixedKey = note.fixedKey || 0;
 			// const svgElement = activeVerticalMeasureList[0]?.vfVoices["1"]?.tickables[si];
-			const svgElement = currenrtVfVoices?.tickables[staveNoteIndex];
+			//const svgElement = currenrtVfVoices?.tickables[staveNoteIndex];
+			// 过滤掉ghostnote
+			const filterTickables = currenrtVfVoices?.tickables?.filter((tickable: any) => tickable.attrs?.type !== "GhostNote")
+			const svgElement = filterTickables?.[staveNoteIndex];
 
 			// console.log('si',si,i)
 			// console.log(note.sourceMeasure.MeasureNumberXML,note,svgElement, NoteRealValue, measureLength)

+ 1 - 1
src/page-instrument/header-top/index.module.less

@@ -34,7 +34,7 @@
         height: 18px;
     }
     &.modeWarnRight {
-        left: "inherit";
+        left: inherit;
         right: 30px;
     }
 }

+ 1 - 1
src/page-instrument/header-top/settting/index.tsx

@@ -62,7 +62,7 @@ export default defineComponent({
                                 </div>
                         }
                         {
-                            state.isSingleLine && state.modeType === "practise" &&
+                            state.isSingleLine && state.modeType === "practise" && !state.isCombineRender && !state.isPercussion && 
                                 <div class={styles.cellBox}>
                                 <div class={styles.tit}>旋律线</div>
                                     <Switch v-model={smoothAnimationState.isShow.value}></Switch>

+ 4 - 0
src/page-instrument/view-detail/smoothAnimation/index.ts

@@ -81,6 +81,10 @@ export function initSmoothAnimation() {
    window.addEventListener("resize", calcClientWidth)
    // 初始化 只有练习模式 才显示
    state.modeType === "practise" && (smoothAnimationState.isShow.value = true)
+   // 多分轨合并显示、打击乐、节奏练习的曲子不显示旋律线
+   if (state.isCombineRender || state.isPercussion) {
+      smoothAnimationState.isShow.value = false
+   }
    console.log(smoothAnimationState, "一行谱小鸟数据")
 }
 

+ 1 - 1
src/page-instrument/view-evaluat-report/component/share-top/index.tsx

@@ -61,7 +61,7 @@ export default defineComponent({
       slow: "#FF7B00",
     };
     // console.log("🚀 ~ scoreData:", scoreData.value)
-    const itemType = ref<IItemType>("intonation");
+    const itemType = ref<IItemType>(state.isPercussion ? "cadence" : "intonation");
     /** 返回 */
     const handleBack = () => {
       api_back();

+ 1 - 1
src/state.ts

@@ -1591,7 +1591,7 @@ export const followBeatPaly = () => {
     metroTimer = null
     return;
   }
-  const time = state.measureTime * 1000 / metronomeData.totalNumerator
+  const time = state.measureTime * 1000 / metronomeData.totalNumerator / state.basePlayRate;
   requestAnimationFrame(() => {
     const endTime = Date.now();
     if (endTime - state.beatStartTime < time) {

+ 16 - 1
src/view/follow-practice/index.tsx

@@ -1,5 +1,5 @@
 import { defineComponent, onMounted, onUnmounted, reactive, ref, watch } from "vue";
-import state, { gotoNext, resetPlaybackToStart, followBeatPaly, skipNotePlay } from "/src/state";
+import state, { gotoNext, resetPlaybackToStart, followBeatPaly, skipNotePlay, initSetPlayRate } from "/src/state";
 import { IPostMessage } from "/src/utils/native-message";
 import { api_cloudFollowTime, api_cloudToggleFollow } from "/src/helpers/communication";
 import { storeData } from "/src/store";
@@ -119,6 +119,7 @@ export const handleFollowStart = async () => {
 		followData.start = true;
 		followData.index = 0;
 		followData.list = [];
+		initSetPlayRate();
 		resetPlaybackToStart();
 		openToggleRecord(true);
 		getNoteIndex();
@@ -138,6 +139,18 @@ export const handleFollowEnd = () => {
 	console.log("结束");
 };
 
+// 清除当前音符右侧的音符的颜色状态
+const clearRightNoteColor = () => {
+	const noteId = state.times[state.activeNoteIndex]?.id;
+	const leftVal = document.getElementById(`vf-${noteId}`)?.getBoundingClientRect()?.left || 0;
+	state.times.forEach((item: any) => {
+		const note: HTMLElement = document.getElementById(`vf-${item.id}`)!;
+		if (note?.getBoundingClientRect()?.left > leftVal) {
+			note.classList.remove("follow-up", "follow-down", "follow-error", "follow-success");
+		}
+	});
+}
+
 /**
  * 2024.6.17 新增自动结束跟练模式功能
  * 如果跟练模式,唱完了最后一个有频率的音符,需要自动结束掉跟练模式
@@ -156,6 +169,7 @@ const autoEndFollow = () => {
 		handleFollowEnd()
 		return
 	}
+	clearRightNoteColor();
 }
 
 // 下一个
@@ -265,6 +279,7 @@ export const skipNotePractice = () => {
 	noteFollows.forEach((noteFollow) => {
 		noteFollow?.classList.remove("follow-up", "follow-down", "follow-error");
 	})
+	clearRightNoteColor();
 }
 
 // 移动到对应音符的位置

+ 1 - 1
src/view/music-score/index.tsx

@@ -219,7 +219,7 @@ export default defineComponent({
 					isInTheGradualRange.value && styles.inGradualRange,
 					state.musicRenderType == EnumMusicRenderType.staff ? "staff" : "jianpuTone",
 					state.isSingleLine && "singleLineMusicBox",
-					!state.isCreateImg ? "blueMusicXml" : ""
+					(!state.isCreateImg && state.musicRenderType === EnumMusicRenderType.staff) ? "blueMusicXml" : ""
 				]}
 			>
 				{slots.default?.()}

+ 1 - 1
src/view/selection/index.module.less

@@ -258,7 +258,7 @@
     }
 
     .follow-success {
-        display: block;
+        // display: block;
         transform-box: fill-box;
         transform-origin: center;
         animation: noteAnimate 1s linear;

+ 2 - 2
src/view/tick/index.tsx

@@ -42,8 +42,8 @@ const tickPlayCb = (i: any, resolve: any, source: any) => {
 		return
 	};
 	tickData.index++;
-	// 当系统节拍器才播放声音
-	if (source && isUseSystemBeat.value) {
+	// 当系统节拍器才播放声音,跟练模式需要播放系统节拍器的声音,评测模式,如果没有伴奏,也需要播放系统节拍器的声音
+	if (source && (isUseSystemBeat.value || state.modeType === 'follow' || (state.modeType === 'evaluating' && !state.accompany)) ) {
 		const beatVolume = state.setting.beatVolume / 100
 		source.volume = beatVolume;
 		if (source.volume <= 0) {