hum2xml - syllabic
Opened this issue · 0 comments
pvankranenburg commented
Currently hum2xml
designates all lyric syllables as single
. It would be great to have the correct syllabic information (single
, begin
, middle
, or end
) based on the dashes in the lyrics.
Example:
**kern **text
*clefG2 *
*M4/4 *
*k[] *
*C: *
=1 =1
4a a
4a syl-
4a -la-
4a -ble.
== ==
*- *-
should result in:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="2.0">
<part-list>
<score-part id="P1">
<part-name></part-name>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>1</divisions>
</attributes>
<attributes>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<attributes>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
</attributes>
<attributes>
<key>
<fifths>0</fifths>
<mode>major</mode>
</key>
</attributes>
<note>
<pitch>
<step>A</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<lyric number="1" name="verse">
<syllabic>single</syllabic>
<text>a</text>
</lyric>
</note>
<note>
<pitch>
<step>A</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<lyric number="1" name="verse">
<syllabic>begin</syllabic>
<text>syl</text>
</lyric>
</note>
<note>
<pitch>
<step>A</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<lyric number="1" name="verse">
<syllabic>middle</syllabic>
<text>la</text>
</lyric>
</note>
<note>
<pitch>
<step>A</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<lyric number="1" name="verse">
<syllabic>end</syllabic>
<text>ble.</text>
</lyric>
</note>
</measure>
</part>
</score-partwise>
So, something like this:
void displayLyrics(HumdrumFile& infile, int line, int col, int verse) {
pline(lev, "<lyric number=\"");
cout << verse << "\" name=\"verse\">\n";
lev++;
string syl = "single";
//find out syllabic information
string text = infile[line][col];
if (text.size() > 0) {
bool first = (text[0] == '-');
bool last = (text[text.size()-1] == '-');
if (first) text.erase(0,1);
if (last) text.erase(text.size()-1,1);
if ( first && last ) syl = "middle";
if ( first && !last) syl = "end";
if ( !first && last) syl = "begin";
}
pline(lev, string("<syllabic>"+syl+"</syllabic>\n").c_str());
pline(lev, "<text>");
displayHTMLText(text.c_str());
cout << "</text>\n";
lev--;
pline(lev, "</lyric>\n");
}