浏览代码

合奏映射声部

liushengqiang 2 年之前
父节点
当前提交
5d53f6b857
共有 4 个文件被更改,包括 243 次插入11 次删除
  1. 1 0
      src/constant/instruments.ts
  2. 215 0
      src/constant/instrumentsClassfiy.ts
  3. 1 0
      src/helpers/formateMusic.ts
  4. 26 11
      src/page-gym/detail/index.tsx

+ 1 - 0
src/constant/instruments.ts

@@ -207,4 +207,5 @@ export const getInstrumentName = (name = '') => {
       return instruments[key]
     }
   }
+  return ''
 };

+ 215 - 0
src/constant/instrumentsClassfiy.ts

@@ -0,0 +1,215 @@
+const instrumentsClassfiy: any = {
+	"2": ["Flute"],
+	"4": ["Clarinet"],
+	"6": ["Soprano Sax", "Alto Sax", "Tenor Sax", "Baritone Sax", "Soprano Saxophone", "Alto Saxophone", "Tenor Saxophone", "Baritone Saxophone"],
+	"12": ["Trumpet", "Muted Trumpet"],
+	"13": ["Horn in F", "French Horn"],
+	"14": ["Trombone"],
+	"15": ["Euphonium"],
+	"17": ["Tuba"],
+	"23": [
+		"Tinkle Bell",
+		"Agogo",
+		"Steel Drums",
+		"Woodblock",
+		"Taiko Drum",
+		"Melodic Tom",
+		"Synth Drums",
+		"Reverse Cymbals",
+		"Acoustic Bass Drum",
+		"Bass Drum",
+		"Side Drum",
+		"Acoustic Snare",
+		"Hand Claps",
+		"Electric Snare",
+		"Low Floor Tom",
+		"Closed Hi-Hat",
+		"High Floor Tom",
+		"Pedal Hi-Hat",
+		"Low Tom",
+		"Open Hi-Hat",
+		"Low-Mid Tom",
+		"Hi Mid Tom",
+		"Crash Cymbals",
+		"High Tom",
+		"Ride Cymbals",
+		"Chinese Cymbals",
+		"Ride Bell",
+		"Tambourine",
+		"Splash Cymbal",
+		"Cowbell",
+		"Crash Cymbal",
+		"Vibra-Slap",
+		"Ride Cymbal",
+		"Hi Bongo",
+		"Low Bongo",
+		"Mute Hi Conga",
+		"Open Hi Conga",
+		"Low Conga",
+		"High Timbale",
+		"Low Timbale",
+		"High Agogo",
+		"Low Agogo",
+		"Cabasa",
+		"Maracas",
+		"Short Whistle",
+		"Long Whistle",
+		"Short Guiro",
+		"Long Guiro",
+		"Claves",
+		"Hi Wood Block",
+		"Low Wood Block",
+		"Mute",
+		"Open",
+		"Mute Triangle",
+		"Open Triangle",
+		"Snare Drum",
+		"Cymbal",
+		"Cymbals",
+		"Triangle",
+		"Vibrato",
+		"Suspend Cymbals",
+		"Suspended Cymbals",
+		"Tom-Toms",
+		"Bell",
+		"Bells",
+		"crash cymbals",
+		"Suspend cymbals",
+		"Castanets",
+		"Drum Set",
+		"Gong",
+		"Shaker",
+		"Mark tree",
+		"Chimes",
+		"Mark Tree",
+		"Tom-toms",
+		"Hi-Hat",
+		"Sleigh Bells",
+		"Flexatone",
+		"Brake drum",
+		"concert tom",
+		"brake drum",
+		"finger cymbal",
+		"ride cymbal",
+		"Concert Toms",
+		"Vibraslap",
+		"Wood Blocks",
+		"Temple Blocks",
+		"Wood Block",
+	],
+	"134": ["Ocarina"],
+	"135": ["Pan Flute"],
+	"136": ["Hulusi flute"],
+	"137": ["Melodica"],
+	Oboe: ["Oboe"],
+	"English Horn": ["English Horn"],
+	Bassoon: ["Bassoon"],
+	Piccolo: ["Piccolo"],
+	Recorder: ["Recorder"],
+	"Soprano Recorder": ["Soprano Recorder"],
+	DYOther: [
+		"Acoustic Grand Piano",
+		"Bright Acoustic Piano",
+		"Electric Grand Piano",
+		"Rhodes Piano",
+		"Chorused Piano",
+		"Harpsichord",
+		"Clavichord",
+		"Celesta",
+		"Glockenspiel",
+		"Music box",
+		"Vibraphone",
+		"Marimba",
+		"Xylophone",
+		"Tubular Bells",
+		"Dulcimer",
+		"Hammond Organ",
+		"Percussive Organ",
+		"Rock Organ",
+		"Church Organ",
+		"Reed Organ",
+		"Accordian",
+		"Harmonica",
+		"Tango Accordian",
+		"Acoustic Guitar",
+		"Electric Guitar",
+		"Overdriven Guitar",
+		"Distortion Guitar",
+		"Guitar Harmonics",
+		"Acoustic Bass",
+		"Electric Bass",
+		"Fretless Bass",
+		"Slap Bass",
+		"Synth Bass",
+		"Violin",
+		"Viola",
+		"Cello",
+		"Contrabass",
+		"Tremolo Strings",
+		"Pizzicato Strings",
+		"Orchestral Harp",
+		"Timpani",
+		"String Ensemble",
+		"Synth Strings",
+		"Choir Aahs",
+		"Voice Oohs",
+		"Synth Voice",
+		"Orchestra Hit",
+		"Brass Section",
+		"Synth Brass",
+		"Bottle Blow",
+		"Whistle",
+		"Lead",
+		"Lead lead",
+		"Pad age",
+		"Pad",
+		"FX",
+		"Sitar",
+		"Banjo",
+		"Shamisen",
+		"Koto",
+		"Kalimba",
+		"Bagpipe",
+		"Fiddle",
+		"Shanai",
+		"Agogos",
+		"Melodic Toms",
+		"Agogo Bells",
+		"Taiko Drums",
+		"Bongos",
+		"Bongo Bell",
+		"Congas",
+		"Guiro",
+		"Guitar Fret Noise",
+		"Breath Noise",
+		"Seashore",
+		"Bird Tweet",
+		"Telephone Ring",
+		"Helicopter",
+		"Applause",
+		"Gunshot",
+		"Bass Clarinet",
+		"Cornet",
+		"Sleigh Bells",
+		"Field Drum",
+		"Quad-Toms",
+		"Quads",
+		"Drums set",
+		"High Bongo",
+		"Timbales",
+	],
+};
+
+export const getInstrumentsClassfiy = (name: string) => {
+	name = name.toLocaleLowerCase().replaceAll(" ", "");
+	for (let key in instrumentsClassfiy) {
+		const names = instrumentsClassfiy[key];
+		for (let i = 0, len = names.length; i < len; i++) {
+			const _key = names[i].toLocaleLowerCase().replaceAll(" ", "");
+			if (_key.includes(name) || name.includes(_key)) {
+				return key;
+			}
+		}
+	}
+  return 0
+};

+ 1 - 0
src/helpers/formateMusic.ts

@@ -795,6 +795,7 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 			// 管乐迷,按自定义按读取到的音符时值
 			if (customNoteCurrentTime) {
 				if (isMutileSubject && currentTimes[i + 1] > 0 && NoteRealValue > currentTimes[i + 1]) {
+					console.log(NoteRealValue, currentTimes[i + 1])
 					NoteRealValue = currentTimes[i + 1];
 				}
 			}

+ 26 - 11
src/page-gym/detail/index.tsx

@@ -27,6 +27,7 @@ import VipModel from "../custom-plugins/vip-verify";
 import GuidePage from "../custom-plugins/guide-page";
 import { handleSetCustomRender, setCustomGradual, setCustomNoteRealValue } from "../custom-plugins/custom-gradual";
 import { getStorageSpeed, setGlobalData } from "/src/utils";
+import { getInstrumentsClassfiy } from "/src/constant/instrumentsClassfiy";
 
 //特殊教材分类id
 const classIds = [1, 30, 97]; // [大雅金唐, 竖笛教程, 声部训练]
@@ -65,10 +66,10 @@ export default defineComponent({
 			const index = query["part-index"] ? parseInt(query["part-index"] as string) : 0;
 			const musicInfo = res.data[index] ? res.data[index] : res.data[0];
 			// console.log("🚀 ~ musicInfo:", musicInfo);
+			state.partListNames = res.data.map((n: any) => n.track);
 			setState(musicInfo, index);
 			setCustom();
 			detailData.isLoading = false;
-			state.partListNames = res.data.map((n: any) => n.track);
 		};
 		const getCategorId = (arr: any[]): any[] => {
 			const list = [];
@@ -94,6 +95,13 @@ export default defineComponent({
 			}
 			return ids;
 		};
+
+		// 获取轨道声部ID
+		const getVoiceSubjectId = () => {
+			const { partListNames, partIndex } = state;
+			const subjectId = getInstrumentsClassfiy(partListNames[partIndex]);
+			return isNaN(Number(subjectId)) ? 0 : Number(subjectId)
+		};
 		/** 获取分类数据 */
 		const getCategory = (res: any) => {
 			detailData.classList = res.data;
@@ -116,8 +124,8 @@ export default defineComponent({
 				} catch (error) {
 					console.error("解析扩展字段错误:", error);
 				}
-				state.gradualTimes = state.extConfigJson.gradualTimes
-				state.repeatedBeats = state.extConfigJson.repeatedBeats || 0
+				state.gradualTimes = state.extConfigJson.gradualTimes;
+				state.repeatedBeats = state.extConfigJson.repeatedBeats || 0;
 			}
 			state.isOpenMetronome = !data.isOpenMetronome;
 			state.needTick = data.isOpenMetronome;
@@ -136,16 +144,23 @@ export default defineComponent({
 			// 是否打击乐
 			state.isPercussion = state.subjectId == 23 || state.subjectId == 113 || state.subjectId == 121 || isRhythmicExercises();
 
-			// 设置指法
-			state.fingeringInfo = subjectFingering(state.subjectId);
-
 			//小曲目 不需要计算音乐的节拍器
 			if (getIds(detailData.classList, [41]).includes(data.parentCategoriesId)) {
 				state.isOpenMetronome = false;
 			}
 			// 设置是否特殊曲谱
-			state.isSpecialBookCategory = !getIds(detailData.classList).includes(state.parentCategoriesId)
+			state.isSpecialBookCategory = !getIds(detailData.classList).includes(state.parentCategoriesId);
 			// console.log('state.isSpecialBookCategory', state.isSpecialBookCategory, state.parentCategoriesId);
+			// 仅在合奏与流行曲目中读取xml声部,否则使用后台设置的声部
+			// this.setMusicUrl()
+			if (state.isSpecialBookCategory) {
+				// console.log(state.partListNames)
+				state.subjectId = getVoiceSubjectId();
+				// console.log("🚀 ~ state.subjectId:", state.subjectId)
+			}
+
+			// 设置指法
+			state.fingeringInfo = subjectFingering(state.subjectId);
 		};
 
 		const setCustom = () => {
@@ -188,11 +203,11 @@ export default defineComponent({
 			} catch (error) {}
 
 			// 设置设置过的速度
-			const storeSpeed = getStorageSpeed(state.examSongId)
-			if (storeSpeed){
-				handleSetSpeed(storeSpeed)
+			const storeSpeed = getStorageSpeed(state.examSongId);
+			if (storeSpeed) {
+				handleSetSpeed(storeSpeed);
 			}
-			handleSetCustomRender()
+			handleSetCustomRender();
 		};
 		/** 指法配置 */
 		const fingerConfig = computed<any>(() => {