Ver código fonte

feat: 变速的曲子,根据当前小节速度

TIANYONG 1 ano atrás
pai
commit
1e674a0c76
3 arquivos alterados com 12 adições e 1 exclusões
  1. 1 0
      src/pages/detail/helpers.ts
  2. 10 0
      src/pages/detail/runtime.ts
  3. 1 1
      vite.config.js

+ 1 - 0
src/pages/detail/helpers.ts

@@ -645,6 +645,7 @@ export const getAllNodes = (osmd: any) => {
             fixedKey,
             realKey: 0,
             duration: 0,
+            measureSpeed, // 小节速度
             formatLyricsEntries: formatLyricsEntries(note),
             stave:
               activeVerticalMeasureList[0] && activeVerticalMeasureList[0].stave

+ 10 - 0
src/pages/detail/runtime.ts

@@ -368,6 +368,15 @@ export const refreshIndexBase = (index: number) => {
   }
 }
 
+// 练习模式下,变速的曲子,根据当前小节速度,设置音频播放倍率
+const dynamicSetPlayRate = (index: number) => {
+  const item: any = detailState.times[index];
+  if (item && modelType.value === "practice" && state.playState === "play" && item.measureSpeed && item.measureSpeed !== detailState.baseSpeed) {
+    const ratio = state.speed / item.measureSpeed
+    state.audiosInstance?.setSpeed(ratio)
+  }
+}
+
 export const refreshIndex = (ctime?: number) => {
   const { osmd }: any = state
   if (osmd && (ctime || state.audiosInstance.audio)) {
@@ -379,6 +388,7 @@ export const refreshIndex = (ctime?: number) => {
     const index = getIndex(detailState.times, currentTimeNum)
     // 监听app返回的ctime
     // console.log(777777777,index,ctime)
+    dynamicSetPlayRate(index);
     state.activeIndex = index
     removeRepateBackground(index)
     // console.log(currentTimeNum, index, detailState.times[detailState.times.length - 1]?.endtime)

+ 1 - 1
vite.config.js

@@ -5,7 +5,7 @@ import glsl from 'vite-plugin-glsl'
 const vueJsx = require('@vitejs/plugin-vue-jsx')
 const legacy = require('@vitejs/plugin-legacy')
 
-const proxyUrl = 'https://test.lexiaoya.cn/' // test 环境
+const proxyUrl = 'https://online.lexiaoya.cn/' // test 环境
 // const proxyUrl = 'http://192.168.3.70:8989/' // test 环境
 // const proxyUrl = 'https://online.colexiu.com/' // online 环境