import { TheoryINote } from "./interface/TheoryINote"; import { TheoryBasicNote } from "./basic/TheoryBasicNote"; import { TheoryFirstLastNote } from "./util/TheoryFirstLastNote"; import { TheoryMeasure } from "../measure/TheoryMeasure"; import { TheoryOnset } from "./util/TheoryOnset"; import { TheoryBeats } from "../beats/TheoryBeats"; import { TheoryDuration } from "./util/TheoryDuration"; import { TheoryTie } from "./util/TheoryTie"; import { Grace } from "./util/TheoryGrace"; import { TheoryAINote } from "./util/TheoryAINote"; export class TheoryNote { private _noteListWithoutGrace: TheoryINote[]; private _graceNoteList: TheoryINote[]; private _xmlNodeList: HTMLCollectionOf; // XML顺序的 note list private _noteListXMLOrder: TheoryINote[]; private _Measure: TheoryMeasure; private _Beats: TheoryBeats; private _basicNote: TheoryBasicNote; // WQQ 优化算法,看看哪些信息可以在一次 for 循环的时候可以合并 private getBasicNoteObjects() { for (let i = 0; i < this._xmlNodeList.length; i++) { let noteXML = this._xmlNodeList[i]; let note = this._basicNote.generateBasicNote(noteXML); // 添加 tie 信息 TheoryTie.addTieInformation(noteXML, note); this._noteListXMLOrder.push(note); } // 添加小节第一个音 和末尾最后一个音属性 TheoryFirstLastNote.addFirstLastNote(this._noteListXMLOrder); Grace.addGraceInformation(this._noteListXMLOrder); } private addOtherInformation2Note() { // 存储 SVG Geometry 信息 this.getGraceNoteList(); // 存储 Onset 信息 TheoryOnset.addNormalNoteOnset(this._noteListWithoutGrace, this._Measure, this._Beats); // 存储 Duration 信息 TheoryDuration.addNoteDuration(this._noteListWithoutGrace, this._Beats); // 存储 graceNote duration 信息 TheoryDuration.addGraceNoteDuration(this._graceNoteList); TheoryOnset.addGraceNoteOnset(this._noteListXMLOrder); TheoryAINote.addAIFirstNote(this._noteListXMLOrder); } private getGraceNoteList() { this._noteListXMLOrder.forEach((note) => { if (!note.isGrace) { this._noteListWithoutGrace.push(note); } else { this._graceNoteList.push(note); } }); } public constructor(xmlNodeList_: HTMLCollectionOf, Measure_: TheoryMeasure, Beats_: TheoryBeats) { this._basicNote = new TheoryBasicNote(); this._xmlNodeList = xmlNodeList_; this._Measure = Measure_; this._Beats = Beats_; this._graceNoteList = []; this._noteListWithoutGrace = []; this._noteListXMLOrder = []; this.getBasicNoteObjects(); this.addOtherInformation2Note(); } public get noteListXMLOrder(): TheoryINote[] { return this._noteListXMLOrder; } }