@@ -92,6 +92,7 @@ export class GpifParser {
92
92
private _lyricsByTrack ! : Map < string , Lyrics [ ] > ;
93
93
private _hasAnacrusis : boolean = false ;
94
94
private _articulationByName ! : Map < string , InstrumentArticulation > ;
95
+ private _skipApplyLyrics : boolean = false ;
95
96
96
97
public parseXml ( xml : string , settings : Settings ) : void {
97
98
this . _masterTrackAutomations = new Map < string , Automation [ ] > ( ) ;
@@ -110,6 +111,8 @@ export class GpifParser {
110
111
this . _noteById = new Map < string , Note > ( ) ;
111
112
this . _tappedNotes = new Map < string , boolean > ( ) ;
112
113
this . _lyricsByTrack = new Map < string , Lyrics [ ] > ( ) ;
114
+ this . _skipApplyLyrics = false ;
115
+
113
116
let dom : XmlDocument ;
114
117
try {
115
118
dom = new XmlDocument ( xml ) ;
@@ -120,7 +123,7 @@ export class GpifParser {
120
123
this . parseDom ( dom ) ;
121
124
this . buildModel ( ) ;
122
125
this . score . finish ( settings ) ;
123
- if ( this . _lyricsByTrack . size > 0 ) {
126
+ if ( ! this . _skipApplyLyrics && this . _lyricsByTrack . size > 0 ) {
124
127
this . _lyricsByTrack . forEach ( ( lyrics , t ) => {
125
128
let track : Track = this . _tracksById . get ( t ) ! ;
126
129
track . applyLyrics ( lyrics ) ;
@@ -1396,12 +1399,32 @@ export class GpifParser {
1396
1399
break ;
1397
1400
}
1398
1401
break ;
1402
+ case 'Lyrics' :
1403
+ beat . lyrics = this . parseBeatLyrics ( c ) ;
1404
+ this . _skipApplyLyrics = true ;
1405
+ break ;
1399
1406
}
1400
1407
}
1401
1408
}
1402
1409
this . _beatById . set ( beatId , beat ) ;
1403
1410
}
1404
1411
1412
+ private parseBeatLyrics ( node : XmlNode ) : string [ ] | null {
1413
+ const lines : string [ ] = [ ] ;
1414
+
1415
+ for ( let c of node . childNodes ) {
1416
+ if ( c . nodeType === XmlNodeType . Element ) {
1417
+ switch ( c . localName ) {
1418
+ case 'Line' :
1419
+ lines . push ( c . innerText ) ;
1420
+ break ;
1421
+ }
1422
+ }
1423
+ }
1424
+
1425
+ return lines ;
1426
+ }
1427
+
1405
1428
private parseBeatXProperties ( node : XmlNode , beat : Beat ) : void {
1406
1429
for ( let c of node . childNodes ) {
1407
1430
if ( c . nodeType === XmlNodeType . Element ) {
0 commit comments