|
@@ -596,7 +596,8 @@ export const formatXML = (xml: string): string => {
|
|
|
if (!xml) return "";
|
|
|
const xmlParse = new DOMParser().parseFromString(xml, "text/xml");
|
|
|
const measures = Array.from(xmlParse.getElementsByTagName("measure"));
|
|
|
- const repeats: any = Array.from(xmlParse.querySelectorAll('repeat'))
|
|
|
+ const repeats: any = Array.from(xmlParse.querySelectorAll('repeat'));
|
|
|
+ compatibleXmlPitchVoice(xmlParse);
|
|
|
// 处理重复小节信息
|
|
|
parseXmlToRepeat(repeats)
|
|
|
// const words: any = xmlParse.getElementsByTagName("words");
|
|
@@ -1127,4 +1128,40 @@ export const verifyCanRepeat = (startNum: number, endNum: number) => {
|
|
|
canRepeat: false
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 兼容处理xml声部移调
|
|
|
+ * 打谱软件可能会自动处理移调,这类型的xml就不用通过程序移调了
|
|
|
+ * 没有通过软件处理的移调xml,才需要通过程序处理
|
|
|
+ * 判读规则:只处理独奏的,不处理合奏的,
|
|
|
+ * <instrument-name></instrument-name>标签的值为:Tenor Recorder(竖笛)、Panpipes(排箫)、Ocarina(陶笛)、空的和solo,需要程序处理移调
|
|
|
+ */
|
|
|
+export const compatibleXmlPitchVoice = (xmlParse: any) => {
|
|
|
+ const partNames = Array.from(xmlParse.getElementsByTagName('part-name'));
|
|
|
+ const partListNames = partNames.map((item: any) => item[0]?.textContent?.trim().toLocaleUpperCase !== "COMMON");
|
|
|
+ if (partListNames.length == 1) {
|
|
|
+ const instrumentNames = Array.from(xmlParse.getElementsByTagName('instrument-name')) || [];
|
|
|
+ // @ts-ignore
|
|
|
+ const instrumentName = instrumentNames[0]?.textContent?.trim()?.toLocaleLowerCase() || ''
|
|
|
+ // console.log('ins名称',instrumentName)
|
|
|
+ // 是否需要程序处理移调
|
|
|
+ let xmlNeedAdjustVoice = false;
|
|
|
+ switch (state.musicalCodeId) {
|
|
|
+ case 37:
|
|
|
+ case 38:
|
|
|
+ xmlNeedAdjustVoice = !instrumentName || instrumentName.includes('solo') || instrumentName.includes('tenor recorder') ? true : false
|
|
|
+ break;
|
|
|
+ case 33:
|
|
|
+ xmlNeedAdjustVoice = !instrumentName || instrumentName.includes('solo') || instrumentName.includes('panpipes') ? true : false
|
|
|
+ break;
|
|
|
+ case 34:
|
|
|
+ xmlNeedAdjustVoice = !instrumentName || instrumentName.includes('solo') || instrumentName.includes('ocarina') ? true : false
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ xmlNeedAdjustVoice = !instrumentName || instrumentName.includes('solo') ? true : false
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ (window as any).xmlNeedAdjustVoice = xmlNeedAdjustVoice
|
|
|
+ }
|
|
|
}
|