MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / parseXml

Method parseXml

packages/alphatab/src/importer/GpifParser.ts:146–185  ·  view source on GitHub ↗
(xml: string, settings: Settings)

Source from the content-addressed store, hash-verified

144 public loadAsset?: (fileName: string) => Uint8Array | undefined;
145
146 public parseXml(xml: string, settings: Settings): void {
147 this._masterTrackAutomations = new Map<number, Automation[]>();
148 this._automationsPerTrackIdAndBarIndex = new Map<string, Map<number, Automation[]>>();
149 this._sustainPedalsPerTrackIdAndBarIndex = new Map<string, Map<number, SustainPedalMarker[]>>();
150 this._tracksMapping = [];
151 this._tracksById = new Map<string, Track>();
152 this._masterBars = [];
153 this._barsOfMasterBar = [];
154 this._voicesOfBar = new Map<string, string[]>();
155 this._barsById = new Map<string, Bar>();
156 this._voiceById = new Map<string, Voice>();
157 this._beatsOfVoice = new Map<string, string[]>();
158 this._beatById = new Map<string, Beat>();
159 this._rhythmOfBeat = new Map<string, string>();
160 this._rhythmById = new Map<string, GpifRhythm>();
161 this._notesOfBeat = new Map<string, string[]>();
162 this._noteById = new Map<string, Note>();
163 this._tappedNotes = new Map<string, boolean>();
164 this._lyricsByTrack = new Map<string, Lyrics[]>();
165 this._soundsByTrack = new Map<string, Map<string, GpifSound>>();
166 this._skipApplyLyrics = false;
167
168 const dom: XmlDocument = new XmlDocument();
169 try {
170 dom.parse(xml);
171 } catch (e) {
172 throw new UnsupportedFormatError('Could not parse XML', e as Error);
173 }
174
175 this._parseDom(dom);
176 this._buildModel();
177 ModelUtils.consolidate(this.score);
178 this.score.finish(settings);
179 if (!this._skipApplyLyrics && this._lyricsByTrack.size > 0) {
180 for (const [t, lyrics] of this._lyricsByTrack) {
181 const track: Track = this._tracksById.get(t)!;
182 track.applyLyrics(lyrics);
183 }
184 }
185 }
186
187 private _parseDom(dom: XmlDocument): void {
188 const root: XmlNode | null = dom.firstElement;

Callers 2

readScoreMethod · 0.95
readScoreMethod · 0.95

Calls 7

parseMethod · 0.95
_parseDomMethod · 0.95
_buildModelMethod · 0.95
consolidateMethod · 0.80
applyLyricsMethod · 0.80
getMethod · 0.65
finishMethod · 0.45

Tested by

no test coverage detected