Browse Source

feat: 管乐迷特殊曲目处理

TIANYONG 1 year ago
parent
commit
aa27878d64

+ 268 - 2
src/helpers/customMusicScore.ts

@@ -1,6 +1,7 @@
 import { ref } from "vue";
-import state from "../state"
+import state, { customData } from "../state"
 import { getQuery } from "/src/utils/queryString";
+import { setGlobalData } from "/src/utils";
 const query: any = getQuery();
 
 interface IItem {
@@ -81,7 +82,8 @@ export const resetGivenFormate = () => {
 	}
 	const tieList = musicList[state.cbsExamSongId as string]
 	if (tieList) {
-		const tie = tieList.find((item) => item.parts.includes(query["part-index"] as string))
+		const partIndex = query["part-index"] || '0'
+		const tie = tieList.find((item) => item.parts.includes(partIndex))
 		if (!tie) return
 		// 延音线和连线重叠
 		if (tie.tieId && tie.tieId.length) {
@@ -523,4 +525,268 @@ const collisionDetection = (a: SVGAElement, b: SVGAElement, distance: number = 0
 			w2: bbbox.width,
 		};
 	}
+};
+
+
+/** 全局曲谱配置 */
+export const setGlobalMusicSheet = () => {
+	const partIndex = query["part-index"] || '0'
+	/** 延音线方向问题 start */
+	const stavetieList = [
+	  {id: '12644', part_index: '25', direction: 1}
+	]
+	const tieItem = stavetieList.find(({id, part_index}) => {
+	  return id == state.cbsExamSongId && part_index == partIndex
+	})
+	setGlobalData('tieDirection', tieItem ? tieItem.direction : undefined)
+	/** 延音线方向问题 end */
+  
+	const graceList = [
+	  {id: '3509', part_index: '16', direction: 1}
+	]
+	const graceItem = graceList.find(({id, part_index}) => {
+	  return id == state.cbsExamSongId && part_index == partIndex
+	})
+	if (graceItem){
+	  setGlobalData('graceCustom', {direction: graceItem.direction})
+	}
+	const bassDrumList = [
+	  {id: '3030', part_index: '17', line: 4},
+	  {id: '12704', part_index: '23', line: 3}
+	]
+	const bassDrumItem = bassDrumList.find(({id, part_index}) => {
+	  return id == state.cbsExamSongId && part_index == partIndex
+	})
+	if (bassDrumItem){
+	  setGlobalData('customBassDrum', bassDrumItem.line)
+	}
+	/** 打击乐多声部,双声部休止符重叠 end */
+  
+	/** 符杆朝向 */
+	const stemDirectionList = [
+	  {
+		id: '11654', 
+		part_index: '16', 
+		stemNotes: [
+		  {id: 124, direction: 0},
+		  {id: 125, direction: 0},
+		  {id: 126, direction: 0},
+		  {id: 127, direction: 0},
+		  {id: 128, direction: 0}
+		]
+	  },
+	  {
+		id: '3581', 
+		part_index: '4', 
+		stemNotes: [
+		  {id: 380, direction: 1},
+		]
+	  },
+	  {
+		id: '3470', 
+		part_index: '0', 
+		stemNotes: [
+		  {id: 36, direction: 1},
+		  {id: 37, direction: 1},
+		]
+	  },
+	  {
+		id: '3470', 
+		part_index: '11', 
+		stemNotes: [
+		  {id: 33, direction: 1},
+		  {id: 56, direction: 1},
+		]
+	  },
+	  {
+		id: '12644', 
+		part_index: '22', 
+		stemNotes: [
+		  {id: 22, direction: 1},
+		  {id: 26, direction: 1},
+		  {id: 135, direction: 1},
+		  {id: 163, direction: 1},
+		  {id: 199, direction: 1},
+		  {id: 204, direction: 1},
+		  {id: 206, direction: 1},
+		  {id: 208, direction: 1},
+		  {id: 210, direction: 1},
+		  {id: 213, direction: 1},
+		]
+	  },
+	  {
+		id: '12303', 
+		part_index: '18', 
+		stemNotes: [
+		  {id: 1, direction: 1},
+		  {id: 4, direction: 1},
+		  {id: 6, direction: 1},
+		  {id: 9, direction: 1},
+		  {id: 12, direction: 1},
+		  {id: 14, direction: 1},
+		]
+	  },
+	  {
+		id: '12669', 
+		part_index: '24', 
+		stemNotes: [
+		  {id: 65, direction: 1},
+		  {id: 296, direction: 1},
+		  {id: 298, direction: 1},
+		  {id: 300, direction: 1},
+		  {id: 338, direction: 1},
+		]
+	  },
+	  {
+		id: '12420', 
+		part_index: '21', 
+		stemNotes: [
+		  {id: 614, direction: 0},
+		  {id: 617, direction: 0},
+		  {id: 619, direction: 0},
+		  {id: 621, direction: 0},
+		]
+	  },
+	  {
+		id: '12711', 
+		part_index: '22', 
+		stemNotes: []
+	  },
+	  {
+		id: '12973', 
+		part_index: '21', 
+		stemNotes: [
+		  {id: 619, direction: 1},
+		  {id: 622, direction: 1},
+		  {id: 745, direction: 1},
+		]
+	  },
+	]
+	const stemDirectionItem = stemDirectionList.find(({id, part_index}) => {
+	  return id == state.cbsExamSongId && part_index == partIndex
+	})
+	if (stemDirectionItem) {
+	  setGlobalData('stemDirectionNote', stemDirectionItem.stemNotes)
+	}
+  
+	/** vfcure */
+	const vfcurveList = [
+	  {
+		id: '12711', 
+		part_index: '4', 
+		vfcurve: [
+		  {MeasureNumberXML: 25, index: 1, bezierEndControlPt: {y: -2}},
+		  {MeasureNumberXML: 33, index: 1, bezierEndControlPt: {y: -2}},
+		]
+	  },
+	  {
+		id: '12059', 
+		part_index: '0', 
+		vfcurve: [
+		  {MeasureNumberXML: 15, bezierEndControlPt: {y: 2.8}, bezierEndPt:{y: 1.1}},
+		  {MeasureNumberXML: 16, bezierEndControlPt: {y: -1}},
+		  {MeasureNumberXML: 19, index: 1, bezierEndControlPt: {y: 2}},
+		  {MeasureNumberXML: 20, bezierEndControlPt: {y: -1}},
+		  {MeasureNumberXML: 42, index: 1, bezierEndControlPt: {y: -1.5}, bezierStartControlPt: {y: -1.5}},
+		  {MeasureNumberXML: 46, index: 3, bezierEndControlPt: {y: -1.5}, bezierStartControlPt: {y: -1.5}},
+		]
+	  },
+	  {
+		id: '12668', 
+		part_index: '11', 
+		vfcurve: [
+		  {MeasureNumberXML: 8, index: 2, bezierEndControlPt: {y: -3}, bezierStartControlPt:{y: -3}, bezierEndPt:{y: -1}},
+		]
+	  },
+	  {
+		id: '11976', 
+		part_index: '0', 
+		vfcurve: [
+		  {MeasureNumberXML: 14, index: 4, bezierEndControlPt: {y: -3}},
+		  {MeasureNumberXML: 14, index: 1, bezierEndPt: {y: 1.5}, bezierEndControlPt: {y: 1}},
+		]
+	  },
+	]
+	const vfcurveItem = vfcurveList.find(({id, part_index}) => {
+	  return id == state.cbsExamSongId && part_index == partIndex
+	})
+	if (vfcurveItem) {
+	  setGlobalData('vfcurveItem', vfcurveItem.vfcurve)
+	}
+	/** drum set声部 重音 */
+	const customArtPositionList = [
+	  {id: '12644', part_index: '25'}
+	]
+	const customArtPositionItem = customArtPositionList.find(({id, part_index}) => {
+	  return id == state.cbsExamSongId && part_index == partIndex
+	})
+	if (customArtPositionItem) {
+	  setGlobalData('customArtPosition', true)
+	}
+	/** 全声部声部 - & 全音符 */
+	const customTenutoList = [
+	  {id: '12645', part_index: '5'}
+	]
+	const customTenutoItem = customTenutoList.find(({id, part_index}) => {
+	  return id == state.cbsExamSongId && part_index == partIndex
+	})
+	if (customTenutoItem) {
+	  setGlobalData('customTenutoItem', true)
+	}
+	/** 全声部声部 >  */
+	const customAccentList = [
+	  {id: '12711', part_index: '22'},
+	  {id: '12711', part_index: '25'},
+	]
+	const customAccentItem = customAccentList.find(({id, part_index}) => {
+	  return id == state.cbsExamSongId && part_index == partIndex
+	})
+	if (customAccentItem) {
+	  setGlobalData('customAccentItem', true)
+	}
+	/** 全声部声部 +  */
+	const customLefthandpizzicatoList = [
+	  {id: '12711', part_index: '25'},
+	  {id: '7755', part_index: '10'},
+	  {id: '6226', part_index: '16'},
+	]
+	const customLefthandpizzicatoItem = customLefthandpizzicatoList.find(({id, part_index}) => {
+	  return id == state.cbsExamSongId && part_index == partIndex
+	})
+	if (customLefthandpizzicatoItem) {
+	  setGlobalData('customLefthandpizzicatoItem', true)
+	}
+}
+
+/** 设置自定义渐慢 */
+export const setCustomGradual = () => {
+	if (state.gradualTimes) {
+		const detailId = state.cbsExamSongId + "";
+		const partIndex = state.partIndex + "";
+		if (["12280"].includes(detailId) && ["24"].includes(partIndex)) {
+			state.gradualTimes["8"] = "00:26:10";
+			state.gradualTimes["66"] = "01:53:35";
+			state.gradualTimes["90"] = "02:41:40";
+		}
+	}
+};
+
+/** 设置自定义音符数据 */
+export const setCustomNoteRealValue = () => {
+	const detailId = state.cbsExamSongId + "";
+    const partIndex = state.partIndex + "";
+	if (["2670"].includes(detailId)) {
+		customData.customNoteRealValue = {
+			0: 0.03125,
+		};
+	}
+	if (["12673"].includes(detailId) && ['22'].includes(partIndex)) {
+		customData.customNoteRealValue = {
+			208: 0.125,
+		};
+	}
+
+    if (["12667", "12673"].includes(detailId)){
+        customData.customNoteCurrentTime = true
+    }
 };

+ 4 - 4
src/helpers/formateMusic.ts

@@ -654,15 +654,15 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 	const { originSpeed: baseSpeed } = state;
 	const formatRealKey = (realKey: number, detail: any) => {
 		// 不是管乐迷, 不处理
-		if (state.appName !== "GYM") return realKey;
+		// if (state.appName !== "GYM") return realKey;
 		// 长笛的LEVEL 2-5-1条练习是泛音练习,以每小节第一个音的指法为准,高音不变变指法。
 		const olnyOneIds = ["906"];
-		if (olnyOneIds.includes(detailId)) {
+		if (olnyOneIds.includes(state.cbsExamSongId)) {
 			return detail.measures[0]?.realKey || realKey;
 		}
 		// 圆号的LEVEL 2-5条练习是泛音练习,最后四小节指法以连音线第一个小节为准
 		const olnyOneIds2 = ["782", "784"];
-		if (olnyOneIds2.includes(detailId)) {
+		if (olnyOneIds2.includes(state.cbsExamSongId)) {
 			const measureNumbers = [14, 16, 30, 32];
 			if (measureNumbers.includes(detail.firstVerticalMeasure?.measureNumber)) {
 				return allNotes[allNotes.length - 1]?.realKey || realKey;
@@ -670,7 +670,7 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 		}
 		// 2-6 第三小节指法按照第一个音符显示
 		const filterIds = ["900", "901", "640", "641", "739", "740", "800", "801", "773", "774", "869", "872", "714", "715"];
-		if (filterIds.includes(detailId)) {
+		if (filterIds.includes(state.cbsExamSongId)) {
 			if (detail.firstVerticalMeasure?.measureNumber === 3 || detail.firstVerticalMeasure?.measureNumber === 9) {
 				return detail.measures[0]?.realKey || realKey;
 			}

+ 3 - 0
src/page-instrument/view-detail/index.tsx

@@ -27,6 +27,7 @@ import { storeData } from "/src/store";
 import ViewFigner from "../view-figner";
 import { recalculateNoteData } from "/src/view/selection";
 import ToggleMusicSheet from "/src/view/plugins/toggleMusicSheet";
+import { setCustomGradual, setCustomNoteRealValue } from "/src/helpers/customMusicScore"
 
 /**
  * 特殊教材分类id
@@ -140,6 +141,8 @@ export default defineComponent({
       if (saveSpeed) {
         handleSetSpeed(saveSpeed);
       }
+      setCustomGradual();
+			setCustomNoteRealValue();
       state.times = formateTimes(osmd);
       state.times = resetFrequency(state.times);
       state.times = setNoteHalfTone(state.times);

+ 144 - 29
src/state.ts

@@ -48,80 +48,195 @@ const classids = [1, 2, 6, 7, 8, 9, 3, 10, 11, 12, 13, 4, 14, 15, 16, 17, 30, 31
 // 乐器code码
 export const musicalInstrumentCodeInfo = [
   {
-    name: '排箫',
-    code: 'Panpipes',
+    name: '长笛',
+    code: 'Flute',
     id: 1
   },
   {
-    name: '笛',
-    code: 'Ocarina',
+    name: '笛',
+    code: 'Piccolo',
     id: 2
   },
   {
-    name: '葫芦丝',
-    code: 'Woodwind',
+    name: '单簧管',
+    code: 'Clarinet',
     id: 3
   },
   {
-    name: '德式竖笛',
-    code: 'Tenor Recorder',
+    name: '低音单簧管',
+    code: 'Bass Clarinet',
     id: 4
   },
   {
-    name: '口风琴',
-    code: 'Nai',
+    name: '中音萨克斯',
+    code: 'Alto Saxophone',
     id: 5
   },
   {
-    name: '英式竖笛',
-    code: 'BaroqueRecorder',
+    name: '次中音萨克斯',
+    code: 'Tenor Saxophone',
     id: 6
   },
   {
-    name: '打击乐',
-    code: 'PERCUSSION',
+    name: '高音萨克斯',
+    code: 'Soprano Saxophone',
     id: 7
   },
   {
-    name: '长笛',
-    code: 'FLUTE',
+    name: '上低音萨克斯',
+    code: 'Baritone Saxophone',
     id: 8
   },
   {
-    name: '萨克斯',
-    code: 'SAX',
+    name: '双簧管',
+    code: 'Oboe',
     id: 9
   },
   {
-    name: '单簧管',
-    code: 'CLARINET',
+    name: '管',
+    code: 'Bassoon',
     id: 10
   },
   {
     name: '小号',
-    code: 'TRUMPET',
+    code: 'Trumpet',
     id: 11
   },
   {
-    name: '号',
-    code: 'TROMBONE',
+    name: '号',
+    code: 'Horn',
     id: 12
   },
   {
-    name: '号',
-    code: 'HORN',
+    name: '号',
+    code: 'Trombone',
     id: 13
   },
   {
     name: '上低音号',
-    code: 'BARITONE',
+    code: 'Baritone',
     id: 14
   },
   {
-    name: '号',
-    code: 'TUBA',
+    name: '次中音号',
+    code: 'Euphonium',
     id: 15
-  }
+  },
+  {
+    name: '大号',
+    code: 'Tuba',
+    id: 16
+  },
+  {
+    name: '钢琴',
+    code: 'Piano',
+    id: 17
+  },
+  {
+    name: '电钢琴',
+    code: 'Electronical Piano',
+    id: 18
+  },
+  {
+    name: '钢片琴',
+    code: 'Glockenspiel',
+    id: 19
+  },
+  {
+    name: '小提琴',
+    code: 'Violin',
+    id: 20
+  },
+  {
+    name: '中提琴',
+    code: 'Viola',
+    id: 21
+  },
+  {
+    name: '大提琴',
+    code: 'Violoncello',
+    id: 22
+  },
+  {
+    name: '低音提琴',
+    code: 'Contrabass',
+    id: 23
+  },
+  {
+    name: '架子鼓',
+    code: 'Drum Set',
+    id: 24
+  },
+  {
+    name: '小鼓',
+    code: 'Snare Drum',
+    id: 25
+  },
+  {
+    name: '马林巴',
+    code: 'Marimba',
+    id: 26
+  },
+  {
+    name: '颤音琴',
+    code: 'Vibraphone',
+    id: 27
+  },
+  {
+    name: '钟琴',
+    code: 'Chimes',
+    id: 28
+  },
+  {
+    name: '木琴',
+    code: 'Xylophone',
+    id: 29
+  },
+  {
+    name: '管钟',
+    code: 'Tubular Bells',
+    id: 30
+  },
+  {
+    name: '定音鼓',
+    code: 'Timpani',
+    id: 31
+  },
+  {
+    name: '键盘',
+    code: 'Mallets',
+    id: 32
+  },
+  {
+    name: '排箫',
+    code: 'Panpipes',
+    id: 33
+  },
+  {
+    name: '陶笛',
+    code: 'Ocarina',
+    id: 34
+  },
+  {
+    name: '葫芦丝',
+    code: 'Woodwind',
+    id: 35
+  },
+  {
+    name: '口风琴',
+    code: 'Nai',
+    id: 36
+  },
+  {
+    name: '德式竖笛',
+    code: 'Tenor Recorder',
+    id: 37
+  },
+  {
+    name: '英式竖笛',
+    code: 'Baroque Recorder',
+    id: 38
+  },
 ]
 
 const state = reactive({

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

@@ -7,7 +7,7 @@ import Selection from "../selection";
 import styles from "./index.module.less";
 import queryString from "query-string";
 import { getGradualLengthByXml } from "/src/helpers/calcSpeed";
-import { resetFormate, resetGivenFormate } from "/src/helpers/customMusicScore"
+import { resetFormate, resetGivenFormate, setGlobalMusicSheet } from "/src/helpers/customMusicScore"
 
 export const musicRenderTypeKey = "musicRenderType";
 
@@ -68,6 +68,7 @@ export default defineComponent({
 		const init = async () => {
 			const container = document.getElementById("musicAndSelection");
 			if (!container || !musicData.score) return;
+			setGlobalMusicSheet();
 			const osmd = new OpenSheetMusicDisplay(container, {
 				drawTitle: false,
 				drawSubtitle: false,