Jelajahi Sumber

feat: 谱面没有速度时,小节默认取后台设置的速度

TIANYONG 8 bulan lalu
induk
melakukan
f38e451c30

+ 2 - 1
osmd-extended/src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -778,8 +778,9 @@ export class InstrumentReader {
 
       // if this is the first measure and no BPM info found, we set it to 120
       // next measures will automatically inherit that value
+      // 谱面没有速度,默认取业务里设置的速度
       if (!this.musicSheet.HasBPMInfo) {
-        this.currentMeasure.TempoInBPM = 120;
+        this.currentMeasure.TempoInBPM = (window as any).baseMeasureSpeed || 120;
       } else if (currentMeasure.TempoInBPM === 0 && this.previousMeasure) {
         this.currentMeasure.TempoInBPM = this.previousMeasure.TempoInBPM;
       }

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

@@ -1113,6 +1113,21 @@ export type InitXmlInfo = {
 export const formatXML = (xml: string, initInfo?: InitXmlInfo): string => {
   if (!xml) return ''
   const xmlParse = new DOMParser().parseFromString(xml, 'text/xml')
+  const minutes = xmlParse.getElementsByTagName("per-minute");
+	let speeds: any = []
+	for (const minute of minutes) {
+		if (minute.textContent && !!Number(minute.textContent)) {
+			speeds.push(Number(minute.textContent))
+		}
+	}
+	speeds = [...new Set(speeds)]
+	const hasVaryingSpeed = speeds.length > 1 ? true : false
+	// 如果谱面和小节都没有打速度,osmd设置的小节速度默认取后台设置的速度
+	if (speeds.length === 0) {
+		;(window as any).baseMeasureSpeed = state.baseSpeed
+	}
+	console.log('是否是变速的曲子:',hasVaryingSpeed,speeds)
+
   const measures = xmlParse.getElementsByTagName('measure')
   let beats = -1
   let beatType = -1

+ 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 环境