fingering-config.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. import { CSSProperties } from "vue";
  2. import relationships from "./fingering-relationships";
  3. export type ITypeFingering = {
  4. json: any;
  5. relationship: any;
  6. height?: number | string;
  7. width?: number | string;
  8. maxWidth?: number;
  9. styles?: CSSProperties;
  10. } | null;
  11. export type IFingering = {
  12. name?: IVocals;
  13. direction?: "vertical" | "transverse";
  14. width?: string;
  15. height?: string;
  16. /** 禁用替指 */
  17. disabledFinger?: boolean;
  18. /** 横竖屏 0:横屏 1: 竖屏 */
  19. orientation?: number;
  20. code?: string;
  21. /** 是否有替指 */
  22. hasTizhi?: boolean;
  23. };
  24. type ITypeContent = {
  25. [key: string | number]: IFingering;
  26. };
  27. export type IVocals =
  28. | "flute"
  29. | "clarinet"
  30. | "saxophone"
  31. | "trumpet"
  32. | "horn"
  33. | "trombone"
  34. | "up-bass-horn"
  35. | "small-drum"
  36. | "tuba"
  37. | "piccolo"
  38. | "piccolo1"
  39. | "piccolo2"
  40. | "hulusi-flute"
  41. | "hulusi-flute1"
  42. | "hulusi-flute2"
  43. | "pan-flute"
  44. | "pan-flute1"
  45. | "pan-flute2"
  46. | "pan-flute3"
  47. | "pan-flute4"
  48. | "ocarina"
  49. | "ocarina1"
  50. | "ocarina2"
  51. | "melodica"
  52. | "melodica1"
  53. | "baroque-recorder"
  54. | "baroque-recorder1"
  55. | "baroque-recorder2";
  56. /** 映射声部ID */
  57. export const mappingVoicePart = (id: number | string, soruce: "GYM" | "COLEXIU" | "ORCHESTRA" | "INSTRUMENT" | "ENSEMBLE"): number => {
  58. if (soruce === "GYM") {
  59. return Number(id);
  60. } else if (soruce === "COLEXIU") {
  61. const subject: { [_key: string | number]: number } = {
  62. Flute: 2,
  63. Clarinet: 4,
  64. Trombone: 14,
  65. Tuba: 17,
  66. Trumpet: 12,
  67. Horn: 13,
  68. AltoSaxophone: 6,
  69. TenorSaxophone: 6,
  70. Saxophone: 6,
  71. UpBassHorn: 15,
  72. Melodica: 137,
  73. HulusiFlute: 136,
  74. PanFlute: 135,
  75. Ocarina: 134,
  76. Recorder: 120,
  77. Ukulele: 130,
  78. Mouthorgan: 140,
  79. Piano: 150,
  80. };
  81. return subject[id];
  82. } else if (soruce === "ORCHESTRA") {
  83. const subject: { [_key: string | number]: number } = {
  84. 1: 23,
  85. 2: 2,
  86. 3: 5,
  87. 4: 4,
  88. 5: 12,
  89. 6: 14,
  90. 7: 13,
  91. 8: 15,
  92. 9: 17,
  93. };
  94. return subject[id];
  95. } else if (soruce === "INSTRUMENT") {
  96. let code = id;
  97. if (typeof code === "string") {
  98. code = code.toLocaleLowerCase().replace(/ /g, "");
  99. }
  100. console.log(code, "1212");
  101. const subject: { [_key: string | number]: any } = {
  102. flute: 2,
  103. clarinet: 4,
  104. trombone: 14,
  105. tuba: 17,
  106. trumpet: 12,
  107. horn: 13,
  108. altosaxophone: 6,
  109. tenorsaxophone: 6,
  110. saxophone: 6,
  111. upbasshorn: 15,
  112. melodica: 137,
  113. hulusiFlute: 136,
  114. panflute: 135,
  115. recorder: 120,
  116. ukulele: 130,
  117. mouthorgan: 140,
  118. piano: 150,
  119. baroquerecorder: 'baroque-recorder',
  120. 4: "piccolo",
  121. 3: "hulusi-flute",
  122. 1: "pan-flute",
  123. 2: "ocarina",
  124. 5: "melodica",
  125. 23: 2,
  126. 24: 6,
  127. 25: 4,
  128. 26: 12,
  129. 27: 14,
  130. 28: 13,
  131. 29: 15,
  132. 30: 17,
  133. tenorrecorder: "piccolo",
  134. woodwind: "hulusi-flute",
  135. panpipes: "pan-flute",
  136. ocarina: "ocarina",
  137. nai: "melodica",
  138. 15: "baroque-recorder",
  139. };
  140. return subject[code] || 0;
  141. } else if (soruce === "ENSEMBLE") {
  142. let code = id;
  143. const subject: { [_key: string | number]: any } = {
  144. Piccolo: "piccolo",
  145. Flute: 2,
  146. "Flute 1": 2,
  147. "Flute 2": 2,
  148. Oboe: 1,
  149. "Clarinet in Bb 1": 4,
  150. "Clarinet in Bb 2": 4,
  151. "Alto Clarinet in Eb": 4,
  152. "Bass Clarinet in Bb": 4,
  153. Bassoon: 1,
  154. "Alto Saxophone": 5,
  155. "Tenor Saxophone": 5,
  156. "Baritone Saxophone": 5,
  157. "Trumpet in Bb 1": 12,
  158. "Trumpet in Bb 2": 12,
  159. "Horn in F": 13,
  160. "Horn in F 1": 13,
  161. "Horn in F 2": 13,
  162. "Trombone 1": 14,
  163. "Trombone 2": 14,
  164. "Trombone 3": 14,
  165. Euphonium: 15,
  166. Tuba: 17,
  167. Chimes: 1,
  168. Bells: 1,
  169. Xylophone: 1,
  170. "Snare Drum": 1,
  171. "Bass Drum": 1,
  172. Triangle: 1,
  173. "Suspended Cymbal": 1,
  174. "Crash Cymbals": 1,
  175. "Concert Toms": 1,
  176. Timpani: 1,
  177. flute: 2,
  178. oboe: 4,
  179. clarinet: 4,
  180. trombone: 14,
  181. tuba: 17,
  182. trumpet: 12,
  183. horn: 13,
  184. altosaxophone: 6,
  185. tenorsaxophone: 6,
  186. saxophone: 6,
  187. upbasshorn: 15,
  188. melodica: 137,
  189. hulusiFlute: 136,
  190. panflute: 135,
  191. recorder: 120,
  192. ukulele: 130,
  193. mouthorgan: 140,
  194. piano: 150,
  195. 4: "piccolo",
  196. 3: "hulusi-flute",
  197. 1: "pan-flute",
  198. 2: "ocarina",
  199. 5: "melodica",
  200. 26: 12,
  201. tenorrecorder: "piccolo",
  202. woodwind: "hulusi-flute",
  203. panpipes: "pan-flute",
  204. ocarina: "ocarina",
  205. nai: "melodica",
  206. BaroqueRecorder: 'baroque-recorder',
  207. };
  208. let _track;
  209. if (typeof code === "string") {
  210. for (let sKey in subject) {
  211. if (sKey === code) {
  212. _track = subject[sKey];
  213. break;
  214. }
  215. }
  216. } else {
  217. _track = subject.code;
  218. }
  219. return _track;
  220. }
  221. return 0;
  222. };
  223. /** 声部的指法配置信息 */
  224. export const subjectFingering = (subjectId: number | string): IFingering => {
  225. switch (subjectId) {
  226. case 2: // 长笛
  227. return {
  228. name: "flute",
  229. direction: "transverse",
  230. height: "1.6rem",
  231. hasTizhi: true,
  232. };
  233. case 4: // 单簧管
  234. return {
  235. name: "clarinet",
  236. direction: "vertical",
  237. width: "3rem",
  238. hasTizhi: true,
  239. };
  240. case 5: // 萨克斯
  241. case 6: // 中音萨克斯
  242. return {
  243. name: "saxophone",
  244. direction: "vertical",
  245. width: "4.34rem",
  246. hasTizhi: true,
  247. };
  248. case 12: // 小号
  249. return {
  250. name: "trumpet",
  251. direction: "transverse",
  252. height: "1.6rem",
  253. hasTizhi: false,
  254. };
  255. case 13: // 圆号
  256. return {
  257. name: "horn",
  258. direction: "vertical",
  259. width: "4.98rem",
  260. hasTizhi: false,
  261. };
  262. case 14: // 长号
  263. return {
  264. name: "trombone",
  265. direction: "transverse",
  266. height: "1.6rem",
  267. hasTizhi: false,
  268. };
  269. case 15: // 上低音号
  270. return {
  271. name: "up-bass-horn",
  272. direction: "vertical",
  273. width: "4.34rem",
  274. hasTizhi: false,
  275. };
  276. case 17: // 大号
  277. return {
  278. name: "tuba",
  279. direction: "vertical",
  280. width: "4.34rem",
  281. hasTizhi: false,
  282. };
  283. case 120: // 短笛
  284. return {
  285. name: "piccolo",
  286. direction: "vertical",
  287. width: "3rem",
  288. orientation: 1,
  289. hasTizhi: true,
  290. };
  291. case "piccolo": // 德式竖笛
  292. return {
  293. name: "piccolo",
  294. direction: "vertical",
  295. width: "3rem",
  296. orientation: 1,
  297. code: "竖笛",
  298. hasTizhi: true,
  299. };
  300. case "hulusi-flute": // 葫芦丝
  301. return {
  302. name: "hulusi-flute",
  303. direction: "vertical",
  304. width: "3rem",
  305. orientation: 1,
  306. code: "葫芦丝",
  307. hasTizhi: false,
  308. };
  309. case "pan-flute": // 排箫
  310. return {
  311. name: "pan-flute",
  312. direction: "transverse",
  313. height: "2rem",
  314. disabledFinger: true,
  315. orientation: 0,
  316. code: "排箫",
  317. hasTizhi: false,
  318. };
  319. case "ocarina": // 陶笛
  320. return {
  321. name: "ocarina",
  322. direction: "vertical",
  323. width: "3rem",
  324. disabledFinger: true,
  325. orientation: 0,
  326. code: "陶笛",
  327. hasTizhi: false,
  328. };
  329. case "melodica": // 口风琴
  330. return {
  331. name: "melodica",
  332. direction: "transverse",
  333. height: "2rem",
  334. orientation: 0,
  335. code: "口风琴",
  336. hasTizhi: false,
  337. };
  338. case "baroque-recorder": // 英式竖笛
  339. return {
  340. name: "baroque-recorder",
  341. direction: "vertical",
  342. width: "3rem",
  343. orientation: 1,
  344. code: "竖笛",
  345. hasTizhi: true,
  346. };
  347. default:
  348. return {};
  349. }
  350. };
  351. export const getFingeringConfig = async (type: IVocals | undefined): Promise<ITypeFingering> => {
  352. switch (type) {
  353. case "flute":
  354. const flute = await import(`./fingering-img/flute/index.json`);
  355. return {
  356. json: flute.default,
  357. relationship: relationships.flute,
  358. height: "60px",
  359. styles: {},
  360. };
  361. case "clarinet":
  362. const clarinet = await import(`./fingering-img/clarinet/index.json`);
  363. return {
  364. json: clarinet.default,
  365. relationship: relationships.clarinet,
  366. styles: {
  367. marginLeft: ".4rem",
  368. marginRight: ".7rem",
  369. },
  370. };
  371. case "trumpet":
  372. const trumpet = await import(`./fingering-img/trumpet/index.json`);
  373. return {
  374. json: trumpet.default,
  375. relationship: relationships.trumpet,
  376. // maxWidth: 150,
  377. };
  378. case "horn":
  379. const horn = await import(`./fingering-img/horn/index.json`);
  380. return {
  381. json: horn.default,
  382. relationship: relationships.horn,
  383. height: "212px",
  384. width: "252px",
  385. };
  386. case "tuba":
  387. const tuba = await import(`./fingering-img/tuba/index.json`);
  388. return {
  389. json: tuba.default,
  390. relationship: relationships.tuba,
  391. };
  392. case "piccolo":
  393. const piccolo = await import(`./fingering-img/piccolo/index.json`);
  394. return {
  395. json: piccolo.default,
  396. relationship: relationships.piccolo,
  397. };
  398. case "piccolo1":
  399. const piccolo1 = await import(`./fingering-img/piccolo1/index.json`);
  400. return {
  401. json: piccolo1.default,
  402. relationship: relationships.piccolo,
  403. };
  404. case "piccolo2":
  405. const piccolo2 = await import(`./fingering-img/piccolo2/index.json`);
  406. return {
  407. json: piccolo2.default,
  408. relationship: relationships.piccolo,
  409. };
  410. case "up-bass-horn":
  411. const upBassHorn = await import(`./fingering-img/up-bass-horn/index.json`);
  412. return {
  413. json: upBassHorn.default,
  414. relationship: relationships["up-bass-horn"],
  415. };
  416. case "trombone":
  417. const trombone = await import(`./fingering-img/trombone/index.json`);
  418. return {
  419. json: trombone.default,
  420. relationship: relationships["trombone"],
  421. };
  422. case "saxophone":
  423. const saxophone = await import(`./fingering-img/saxophone/index.json`);
  424. return {
  425. json: saxophone.default,
  426. relationship: relationships["saxophone"],
  427. styles: {
  428. marginLeft: ".2rem",
  429. marginRight: ".3rem",
  430. },
  431. };
  432. case "small-drum":
  433. const smallDrum = await import(`./fingering-img/small-drum/index.json`);
  434. return {
  435. json: smallDrum.default,
  436. relationship: relationships["up-bass-horn"],
  437. width: "180px",
  438. };
  439. case "hulusi-flute":
  440. const hulusi = await import(`./fingering-img/hulusi-flute/index.json`);
  441. return {
  442. json: hulusi.default,
  443. relationship: relationships.hulusi,
  444. // width: '180px',
  445. styles: {
  446. marginLeft: ".6rem",
  447. marginRight: ".7rem",
  448. },
  449. };
  450. case "hulusi-flute1":
  451. const hulusi1 = await import(`./fingering-img/hulusi-flute1/index.json`);
  452. return {
  453. json: hulusi1.default,
  454. relationship: relationships.hulusi,
  455. // width: '180px',
  456. styles: {
  457. marginLeft: ".6rem",
  458. marginRight: ".7rem",
  459. },
  460. };
  461. case "hulusi-flute2":
  462. const hulusi2 = await import(`./fingering-img/hulusi-flute2/index.json`);
  463. return {
  464. json: hulusi2.default,
  465. relationship: relationships.hulusi,
  466. // width: '180px',
  467. styles: {
  468. marginLeft: ".6rem",
  469. marginRight: ".7rem",
  470. },
  471. };
  472. case "pan-flute":
  473. const pan = await import(`./fingering-img/pan-flute/index.json`);
  474. return {
  475. json: pan.default,
  476. relationship: relationships.pan,
  477. };
  478. case "pan-flute1":
  479. const pan1 = await import(`./fingering-img/pan-flute1/index.json`);
  480. return {
  481. json: pan1.default,
  482. relationship: relationships.pan,
  483. };
  484. case "pan-flute2":
  485. const pan2 = await import(`./fingering-img/pan-flute2/index.json`);
  486. return {
  487. json: pan2.default,
  488. relationship: relationships.pan,
  489. };
  490. case "pan-flute3":
  491. const pan3 = await import(`./fingering-img/pan-flute3/index.json`);
  492. return {
  493. json: pan3.default,
  494. relationship: relationships.pan,
  495. };
  496. case "ocarina":
  497. const ocarina = await import(`./fingering-img/ocarina/index.json`);
  498. return {
  499. json: ocarina.default,
  500. relationship: relationships.ocarina,
  501. width: "180px",
  502. styles: {
  503. marginTop: "auto",
  504. },
  505. };
  506. case "ocarina1":
  507. const ocarina1 = await import(`./fingering-img/ocarina1/index.json`);
  508. return {
  509. json: ocarina1.default,
  510. relationship: relationships.ocarina,
  511. width: "180px",
  512. styles: {
  513. marginTop: "auto",
  514. },
  515. };
  516. case "ocarina2":
  517. const ocarina2 = await import(`./fingering-img/ocarina2/index.json`);
  518. return {
  519. json: ocarina2.default,
  520. relationship: relationships.ocarina,
  521. width: "180px",
  522. styles: {
  523. marginTop: "auto",
  524. },
  525. };
  526. case "melodica":
  527. const melodica = await import(`./fingering-img/melodica/index.json`);
  528. return {
  529. json: melodica.default,
  530. relationship: relationships.melodica,
  531. height: "80px",
  532. styles: {
  533. marginTop: "auto",
  534. },
  535. };
  536. case "melodica1":
  537. const melodica1 = await import(`./fingering-img/melodica1/index.json`);
  538. return {
  539. json: melodica1.default,
  540. relationship: relationships.melodica,
  541. height: "80px",
  542. styles: {
  543. marginTop: "auto",
  544. },
  545. };
  546. case "baroque-recorder":
  547. const baroqueRecorder = await import(`./fingering-img/baroque-recorder/index.json`);
  548. return {
  549. json: baroqueRecorder.default,
  550. relationship: relationships.baroqueRecorder,
  551. };
  552. case "baroque-recorder1":
  553. const baroqueRecorder1 = await import(`./fingering-img/baroque-recorder1/index.json`);
  554. return {
  555. json: baroqueRecorder1.default,
  556. relationship: relationships.baroqueRecorder,
  557. };
  558. case "baroque-recorder2":
  559. const baroqueRecorder2 = await import(`./fingering-img/baroque-recorder2/index.json`);
  560. return {
  561. json: baroqueRecorder2.default,
  562. relationship: relationships.baroqueRecorder,
  563. };
  564. default:
  565. return null;
  566. }
  567. };