Lyric.parse constructor
Lyric.parse(
- XmlElement xmlLyric,
- MusicXMLParserState state
Parse the MusicXML
Implementation
factory Lyric.parse(XmlElement xmlLyric, MusicXMLParserState state) {
final items = <LyricItem>[];
Syllabic? syllabic;
String? text;
String? name;
String? elision;
for (final child in xmlLyric.childElements) {
switch (child.name.local) {
case 'syllabic':
syllabic = Syllabic.values
.firstWhere((e) => e.toString() == 'Syllabic.' + child.innerText);
break;
case 'text':
text = child.innerText;
break;
case 'elision':
items.add(LyricItem(syllabic, text!, elision));
elision = child.innerText;
syllabic = null;
text = null;
break;
default:
// Ignore other tag types because they are not relevant to Magenta.
}
}
if (text == null) {
text = '';
}
items.add(LyricItem(syllabic, text, elision));
name = _parseName(xmlLyric.attributes);
return Lyric(items, name);
}