Closed jacekiwaszko1 closed 4 years ago
There are three possible ways to fix the problem:
(1) the one you mention: convert the newline into a space
(2) preserve the newline as \n
in the text, and this would be converted to <lb>
in the conversion to MEI (I don't know if verovio handles this yet, but I would expect so). In the general case this is probably the best solution if already possible in verovio, otherwise I could implement (1) easily, and then later switch to (2).
(3) split the text into two separate text layouts. This would work almost the same as (2) and I currently do that manually in Humdrum data when I want multi-line text in verovio or musedata.
<lb/>
works with MEI in Verovio:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="4.0.0">
<meiHead>
<fileDesc>
<titleStmt>
<title />
</titleStmt>
<pubStmt />
</fileDesc>
<encodingDesc>
<appInfo>
<application isodate="2019-12-13T09:33:50" version="2.4.0-dev-d493c9f">
<name>Verovio</name>
<p>Transcoded from Humdrum</p>
</application>
</appInfo>
</encodingDesc>
<workList>
<work>
<title />
</work>
</workList>
</meiHead>
<music>
<body>
<mdiv xml:id="mdiv-0000000271366071">
<score xml:id="score-0000002011660787">
<scoreDef xml:id="scoredef-0000001811498220" midi.bpm="400">
<staffGrp xml:id="staffgrp-0000000187619253" symbol="brace" bar.thru="true">
<labelAbbr xml:id="labelAbbr-0000000362742844" />
<staffDef xml:id="staffdef-0000001626578671" n="1" lines="5">
<clef xml:id="clef-0000001344917466" shape="G" line="2" />
</staffDef>
<staffDef xml:id="staffdef-0000001154931042" n="2" lines="5">
<clef xml:id="clef-0000001780004723" shape="F" line="4" />
</staffDef>
</staffGrp>
</scoreDef>
<section xml:id="section-L1F1">
<measure xml:id="measure-L1" right="end" n="0">
<staff xml:id="staff-0000000472078502" n="1">
<layer xml:id="layer-L1F2N1" n="1">
<note xml:id="note-L4F2" dur="1" oct="5" pname="c" accid.ges="n" />
</layer>
</staff>
<staff xml:id="staff-0000001876897635" n="2">
<layer xml:id="layer-L1F1N1" n="1">
<note xml:id="note-L4F1" dur="1" oct="3" pname="c" accid.ges="n" />
</layer>
</staff>
<dir xml:id="dir-L4F2" place="above" staff="1" tstamp="1.000000">
<rend xml:id="rend-0000000819620543" fontstyle="normal">note<lb/>with newline</rend>
</dir>
</measure>
</section>
</score>
</mdiv>
</body>
</music>
</mei>
rendering:
The problem is now that humdrum-to-MEI converter converts <lb/>
to <lb/>
and Verovio displays
as text:
**kern **kern
= =
! !LO:TX:a:t=note<lb/>with newline
1C 1cc
== ==
*- *-
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="4.0.0">
<meiHead>
<fileDesc>
<titleStmt>
<title />
</titleStmt>
<pubStmt />
</fileDesc>
<encodingDesc>
<appInfo>
<application isodate="2019-12-13T09:40:23" version="2.4.0-dev-d493c9f">
<name>Verovio</name>
<p>Transcoded from Humdrum</p>
</application>
</appInfo>
</encodingDesc>
<workList>
<work>
<title />
</work>
</workList>
</meiHead>
<music>
<body>
<mdiv xml:id="mdiv-0000000912570160">
<score xml:id="score-0000001580762930">
<scoreDef xml:id="scoredef-0000000694418648" midi.bpm="400">
<staffGrp xml:id="staffgrp-0000000718066140" symbol="brace" bar.thru="true">
<labelAbbr xml:id="labelAbbr-0000000724637648" />
<staffDef xml:id="staffdef-0000001010027453" n="1" lines="5">
<clef xml:id="clef-0000001337470829" shape="G" line="2" />
</staffDef>
<staffDef xml:id="staffdef-0000000938657568" n="2" lines="5">
<clef xml:id="clef-0000000774556622" shape="F" line="4" />
</staffDef>
</staffGrp>
</scoreDef>
<section xml:id="section-L1F1">
<measure xml:id="measure-L1" right="end" n="0">
<staff xml:id="staff-0000002003659188" n="1">
<layer xml:id="layer-L1F2N1" n="1">
<note xml:id="note-L4F2" dur="1" oct="5" pname="c" accid.ges="n" />
</layer>
</staff>
<staff xml:id="staff-0000001006979272" n="2">
<layer xml:id="layer-L1F1N1" n="1">
<note xml:id="note-L4F1" dur="1" oct="3" pname="c" accid.ges="n" />
</layer>
</staff>
<dir xml:id="dir-L4F2" place="above" staff="1" tstamp="1.000000">
<rend xml:id="rend-0000001716572797" fontstyle="normal">note<lb/>with newline</rend>
</dir>
</measure>
</section>
</score>
</mdiv>
</body>
</music>
</mei>
There's also related problem with conversion of xml to humdrum. First example in this issue was created with MuseScore and slightly changed to achieve the way how Finale converts multiline text expressions. MuseScore by itself splits multiline texts into separate lines:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.1">
<identification>
<encoding>
<software>MuseScore 2.3.2</software>
<encoding-date>2019-12-13</encoding-date>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="print" attribute="new-page" type="yes" value="yes"/>
<supports element="print" attribute="new-system" type="yes" value="yes"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<defaults>
<scaling>
<millimeters>7.05556</millimeters>
<tenths>40</tenths>
</scaling>
<page-layout>
<page-height>1683.36</page-height>
<page-width>1190.88</page-width>
<page-margins type="even">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
</page-layout>
<word-font font-family="FreeSerif" font-size="10"/>
<lyric-font font-family="FreeSerif" font-size="11"/>
</defaults>
<part-list>
<score-part id="P1">
<part-name>Piano</part-name>
<part-abbreviation>Pno.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Piano</instrument-name>
</score-instrument>
<midi-device id="P1-I1" port="1"></midi-device>
<midi-instrument id="P1-I1">
<midi-channel>1</midi-channel>
<midi-program>1</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1" width="185.20">
<print>
<system-layout>
<system-margins>
<left-margin>21.00</left-margin>
<right-margin>609.23</right-margin>
</system-margins>
<top-system-distance>170.00</top-system-distance>
</system-layout>
<staff-layout number="2">
<staff-distance>65.00</staff-distance>
</staff-layout>
</print>
<attributes>
<divisions>1</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<staves>2</staves>
<clef number="1">
<sign>G</sign>
<line>2</line>
</clef>
<clef number="2">
<sign>F</sign>
<line>4</line>
</clef>
</attributes>
<note default-x="77.35" default-y="-15.00">
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>whole</type>
<staff>1</staff>
</note>
<backup>
<duration>4</duration>
</backup>
<direction placement="above">
<direction-type>
<words default-y="40.00" relative-x="-9.47" relative-y="2.71">note
</words>
<words>with newline</words>
</direction-type>
<staff>2</staff>
</direction>
<note default-x="77.35" default-y="-130.00">
<pitch>
<step>C</step>
<octave>3</octave>
</pitch>
<duration>4</duration>
<voice>5</voice>
<type>whole</type>
<staff>2</staff>
</note>
</measure>
<measure number="2" width="126.53">
<note default-x="12.00" default-y="-20.00">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>whole</type>
<staff>1</staff>
</note>
<backup>
<duration>4</duration>
</backup>
<note default-x="12.00" default-y="-125.00">
<pitch>
<step>D</step>
<octave>3</octave>
</pitch>
<duration>4</duration>
<voice>5</voice>
<type>whole</type>
<staff>2</staff>
</note>
</measure>
<measure number="3" width="135.53">
<note default-x="12.00" default-y="-25.00">
<pitch>
<step>A</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>whole</type>
<staff>1</staff>
</note>
<backup>
<duration>4</duration>
</backup>
<note default-x="12.00" default-y="-120.00">
<pitch>
<step>E</step>
<octave>3</octave>
</pitch>
<duration>4</duration>
<voice>5</voice>
<type>whole</type>
<staff>2</staff>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
In conversion with the second line disapears for some reason:
**kern **kern
*part1 *part1
*staff2 *staff1
*I"Piano *
*I'Pno. *
*clefF4 *clefG2
*k[] *k[]
*M4/4 *M4/4
= =
! !LO:TX:a:t=note
1C 1cc
=3 =3
1D 1b
=4 =4
1E 1a
== ==
*- *-
!!!system-decoration: {(s1,s2)}
For the Humdrum to MEI conversion I will convert \n
characters into <lb/>
elements. I probably will not allow <lb>
directly in Humdrum since XML has problems with angle brackets (so I convert angle brackets into <
and >
. In other words, I would not know if <xxx>
is supposed to be displayed as literal text, or converted into an XML element.
For the MusicXML to Humdrum converter, I will convert such text:
<direction-type>
<words default-y="40.00" relative-x="-9.47" relative-y="2.71">note
</words>
<words>with newline</words>
into note\nwith newline
. There are a couple of possibilities. Probably if I see multiple <words>
in the MusicXML <direction-type>
I will assume they are separated by a newline. There is a newline in the data, but I do not know if that is triggering the newline in the notation, or if the multiple <words>
are triggering the newline.... Typically space/newlines characters surrounding text in XML data is ignored, so perhaps the newline in the MusicXML data example is also being ignored.
If the newline character is removed, then the newline (and space) in the display in MuseScore is removed as well:
<direction placement="above">
<direction-type>
<words default-y="40.00" relative-x="-9.47" relative-y="2.71">note</words>
<words>with newline</words>
</direction-type>
<staff>2</staff>
</direction>
Original:
<direction placement="above">
<direction-type>
<words default-y="40.00" relative-x="-9.47" relative-y="2.71">note
</words>
<words>with newline</words>
</direction-type>
<staff>2</staff>
</direction>
So whitespace around the text is important (usually ignored in XML data)
Commit https://github.com/craigsapp/humlib/commit/b2cdd6598216da0f33726f829abe8bd7de763ff1 sets the conversion to Humdrum from MusicXML as:
**kern **kern
*part1 *part1
*staff2 *staff1
*I"Piano *
*I'Pno. *
*clefF4 *clefG2
*k[] *k[]
*M4/4 *M4/4
= =
! !LO:TX:a:t=note\nwith newline
1C 1cc
=3 =3
1D 1b
=4 =4
1E 1a
== ==
*- *-
!!!system-decoration: {(s1,s2)}
Commit https://github.com/rism-ch/verovio/commit/7e6ed7b9dca607c77a21ef82b20c79e33adcdc77 implements the Humdrum-to-MEI line breaks.
Example:
**kern **kern
*part1 *part1
*staff2 *staff1
*I"Piano *
*I'Pno. *
*clefF4 *clefG2
*k[] *k[]
*M4/4 *M4/4
= =
! !LO:TX:a:t=note\nwith newline
1C 1cc
=3 =3
!!LO:TX:b:i:t=global\nmultiline note
1D 1b
=4 =4
1E 1a
== ==
*- *-
!!!system-decoration: {(s1,s2)}
MEI conversion:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="https://music-encoding.org/schema/4.0.0/mei-all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<mei xmlns="http://www.music-encoding.org/ns/mei" meiversion="4.0.0">
<meiHead>
<fileDesc>
<titleStmt>
<title />
</titleStmt>
<pubStmt />
</fileDesc>
<encodingDesc>
<appInfo>
<application isodate="2019-12-16T11:31:08" version="2.4.0-dev-7efa432">
<name>Verovio</name>
<p>Transcoded from Humdrum</p>
</application>
</appInfo>
</encodingDesc>
<workList>
<work>
<title />
</work>
</workList>
<extMeta>
<frames xmlns="http://www.humdrum.org/ns/humxml">
<metaFrame n="18" token="!!!system-decoration: {(s1,s2)}" xml:id="L19">
<frameInfo>
<startTime float="12" />
<frameType>reference</frameType>
<referenceKey>system-decoration</referenceKey>
<referenceValue>{(s1,s2)}</referenceValue>
</frameInfo>
</metaFrame>
</frames>
</extMeta>
</meiHead>
<music>
<body>
<mdiv xml:id="mdiv-0000000177161516">
<score xml:id="score-0000001141264670">
<scoreDef xml:id="scoredef-0000002058947382" midi.bpm="400">
<staffGrp xml:id="staffgrp-0000002012420726" symbol="brace" bar.thru="true">
<label xml:id="label-0000000455563603">Piano</label>
<labelAbbr xml:id="labelAbbr-0000002106785435">Pno.</labelAbbr>
<staffDef xml:id="staffdef-0000000811191620" n="1" lines="5">
<clef xml:id="clef-L6F2" shape="G" line="2" />
<keySig xml:id="keysig-L7F2" sig="0" />
<meterSig xml:id="metersig-L8F2" count="4" unit="4" />
</staffDef>
<staffDef xml:id="staffdef-0000000938993617" n="2" lines="5">
<clef xml:id="clef-L6F1" shape="F" line="4" />
<keySig xml:id="keysig-L7F1" sig="0" />
<meterSig xml:id="metersig-L8F1" count="4" unit="4" />
</staffDef>
</staffGrp>
</scoreDef>
<section xml:id="section-L1F1">
<measure xml:id="measure-L1" n="0">
<staff xml:id="staff-0000000507413402" n="1">
<layer xml:id="layer-L1F2N1" n="1">
<note xml:id="note-L11F2" dur="1" oct="5" pname="c" accid.ges="n" />
</layer>
</staff>
<staff xml:id="staff-0000000439485177" n="2">
<layer xml:id="layer-L1F1N1" n="1">
<note xml:id="note-L11F1" dur="1" oct="3" pname="c" accid.ges="n" />
</layer>
</staff>
<dir xml:id="dir-L11F2" place="above" staff="1" tstamp="1.000000">
<rend xml:id="rend-0000001361264569" fontstyle="normal">note<lb xml:id="lb-0000001039211371" />with newline</rend>
</dir>
</measure>
<measure xml:id="measure-L12" n="3">
<staff xml:id="staff-L12F2N1" n="1">
<layer xml:id="layer-L12F2N1" n="1">
<note xml:id="note-L14F2" dur="1" oct="4" pname="b" accid.ges="n" />
</layer>
</staff>
<staff xml:id="staff-L12F1N1" n="2">
<layer xml:id="layer-L12F1N1" n="1">
<note xml:id="note-L14F1" dur="1" oct="3" pname="d" accid.ges="n" />
</layer>
</staff>
<dir xml:id="dir-L14F1" place="below" staff="2" tstamp="1.000000">global<lb xml:id="lb-0000000675457552" />multiline note</dir>
</measure>
<measure xml:id="measure-L15" right="end" n="4">
<staff xml:id="staff-L15F2N1" n="1">
<layer xml:id="layer-L15F2N1" n="1">
<note xml:id="note-L16F2" dur="1" oct="4" pname="a" accid.ges="n" />
</layer>
</staff>
<staff xml:id="staff-L15F1N1" n="2">
<layer xml:id="layer-L15F1N1" n="1">
<note xml:id="note-L16F1" dur="1" oct="3" pname="e" accid.ges="n" />
</layer>
</staff>
</measure>
</section>
</score>
</mdiv>
</body>
</music>
</mei>
Works for both local and global text messages.
Drag-and-drop of test MusicXML file (last one), which runs through both MusicXML-to-Humdrum converter and Humdrum-to-MEI converter:
Newline character in text note saved in XML file causes problem with the conversion: XML:
and conversion output with error:
Would it be possible to ignore newline characters or to substitute them to space in conversion?