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

Method _parseTrack

packages/alphatab/src/importer/GpifParser.ts:604–686  ·  view source on GitHub ↗
(node: XmlNode)

Source from the content-addressed store, hash-verified

602 }
603
604 private _parseTrack(node: XmlNode): void {
605 this._articulationByName = new Map<string, InstrumentArticulation>();
606
607 const track: Track = new Track();
608 track.ensureStaveCount(1);
609 const staff: Staff = track.staves[0];
610 staff.showStandardNotation = true;
611 const trackId: string = node.getAttribute('id');
612
613 for (const c of node.childElements()) {
614 switch (c.localName) {
615 case 'Name':
616 track.name = c.innerText;
617 break;
618 case 'Color':
619 const parts: string[] = GpifParser._splitSafe(c.innerText);
620 if (parts.length >= 3) {
621 const r: number = GpifParser._parseIntSafe(parts[0], 0);
622 const g: number = GpifParser._parseIntSafe(parts[1], 0);
623 const b: number = GpifParser._parseIntSafe(parts[2], 0);
624 track.color = new Color(r, g, b, 0xff);
625 }
626 break;
627 case 'Instrument':
628 const instrumentName: string = c.getAttribute('ref');
629 if (instrumentName.endsWith('-gs') || instrumentName.endsWith('GrandStaff')) {
630 track.ensureStaveCount(2);
631 track.staves[1].showStandardNotation = true;
632 }
633 break;
634 case 'InstrumentSet':
635 this._parseInstrumentSet(track, c);
636 break;
637 case 'NotationPatch':
638 this._parseNotationPatch(track, c);
639 break;
640 case 'ShortName':
641 track.shortName = c.innerText;
642 break;
643 case 'SystemsDefautLayout': // not a typo by alphaTab, this is a typo in the GPIF files.
644 track.defaultSystemsLayout = GpifParser._parseIntSafe(c.innerText, 4);
645 break;
646 case 'SystemsLayout':
647 track.systemsLayout = GpifParser._splitSafe(c.innerText).map(i => GpifParser._parseIntSafe(i, 4));
648 break;
649 case 'Lyrics':
650 this._parseLyrics(trackId, c);
651 break;
652 case 'Properties':
653 this._parseTrackProperties(track, c);
654 break;
655 case 'GeneralMidi':
656 case 'MidiConnection':
657 case 'MIDISettings':
658 this._parseGeneralMidi(track, c);
659 break;
660 case 'Sounds':
661 this._parseSounds(trackId, track, c);

Callers 1

_parseTracksNodeMethod · 0.95

Calls 15

ensureStaveCountMethod · 0.95
_parseInstrumentSetMethod · 0.95
_parseNotationPatchMethod · 0.95
_parseLyricsMethod · 0.95
_parseTrackPropertiesMethod · 0.95
_parseGeneralMidiMethod · 0.95
_parseSoundsMethod · 0.95
_parsePartSoundingMethod · 0.95
_parseStavesMethod · 0.95
_parseTransposeMethod · 0.95
_parseRSEMethod · 0.95

Tested by

no test coverage detected