humdrum-tools / verovio-humdrum-viewer

Verovio Humdrum Viewer
http://verovio.humdrum.org
37 stars 9 forks source link

tremolo and grace note colision in conversion from musicXML #305

Open jacekiwaszko1 opened 4 years ago

jacekiwaszko1 commented 4 years ago

The following musicXML (prepared in MuseScore 3) is not converted properly:

tup-trem-conv-err

<?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 3.4.2</software>
      <encoding-date>2020-05-15</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.056</millimeters>
      <tenths>40</tenths>
      </scaling>
    <page-layout>
      <page-height>1683.28</page-height>
      <page-width>1190.82</page-width>
      <page-margins type="even">
        <left-margin>566.893</left-margin>
        <right-margin>56.6893</right-margin>
        <top-margin>56.6893</top-margin>
        <bottom-margin>113.379</bottom-margin>
        </page-margins>
      <page-margins type="odd">
        <left-margin>56.6893</left-margin>
        <right-margin>566.893</right-margin>
        <top-margin>56.6893</top-margin>
        <bottom-margin>113.379</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></part-name>
      <score-instrument id="P1-I1">
        <instrument-name>Voce</instrument-name>
        </score-instrument>
      <midi-device id="P1-I1" port="1"></midi-device>
      <midi-instrument id="P1-I1">
        <midi-channel>2</midi-channel>
        <midi-program>53</midi-program>
        <volume>78.7402</volume>
        <pan>0</pan>
        </midi-instrument>
      </score-part>
    <score-part id="P2">
      <part-name></part-name>
      <score-instrument id="P2-I1">
        <instrument-name>Voce</instrument-name>
        </score-instrument>
      <midi-device id="P2-I1" port="1"></midi-device>
      <midi-instrument id="P2-I1">
        <midi-channel>1</midi-channel>
        <midi-program>53</midi-program>
        <volume>78.7402</volume>
        <pan>0</pan>
        </midi-instrument>
      </score-part>
    </part-list>
  <part id="P1">
    <measure number="1" width="567.23">
      <print>
        <system-layout>
          <system-margins>
            <left-margin>0.00</left-margin>
            <right-margin>0.00</right-margin>
            </system-margins>
          <top-system-distance>70.00</top-system-distance>
          </system-layout>
        </print>
      <attributes>
        <divisions>4</divisions>
        <key>
          <fifths>0</fifths>
          </key>
        <time>
          <beats>4</beats>
          <beat-type>4</beat-type>
          </time>
        <clef>
          <sign>G</sign>
          <line>2</line>
          </clef>
        </attributes>
      <note default-x="91.23" default-y="-35.00">
        <pitch>
          <step>F</step>
          <octave>4</octave>
          </pitch>
        <duration>4</duration>
        <voice>1</voice>
        <type>quarter</type>
        <stem>up</stem>
        </note>
      <note>
        <rest/>
        <duration>4</duration>
        <voice>1</voice>
        <type>quarter</type>
        </note>
      <note default-x="273.71" default-y="-35.00">
        <pitch>
          <step>F</step>
          <octave>4</octave>
          </pitch>
        <duration>8</duration>
        <voice>1</voice>
        <type>half</type>
        <stem>up</stem>
        <notations>
          <ornaments>
            <tremolo type="single">1</tremolo>
            </ornaments>
          </notations>
        </note>
      <barline location="right">
        <bar-style>light-heavy</bar-style>
        </barline>
      </measure>
    </part>
  <part id="P2">
    <measure number="1" width="567.23">
      <print>
        <staff-layout number="1">
          <staff-distance>65.00</staff-distance>
          </staff-layout>
        </print>
      <attributes>
        <divisions>4</divisions>
        <key>
          <fifths>0</fifths>
          </key>
        <time>
          <beats>4</beats>
          <beat-type>4</beat-type>
          </time>
        <clef>
          <sign>G</sign>
          <line>2</line>
          </clef>
        </attributes>
      <note default-x="90.87" default-y="-115.00">
        <pitch>
          <step>D</step>
          <octave>5</octave>
          </pitch>
        <duration>8</duration>
        <voice>1</voice>
        <type>half</type>
        <stem>down</stem>
        <notations>
          <ornaments>
            <tremolo type="single">1</tremolo>
            </ornaments>
          </notations>
        </note>
      <note default-x="274.07" default-y="-115.00">
        <pitch>
          <step>D</step>
          <octave>5</octave>
          </pitch>
        <duration>2</duration>
        <voice>1</voice>
        <type>eighth</type>
        <stem>down</stem>
        <beam number="1">begin</beam>
        </note>
      <note default-x="340.55" default-y="-115.00">
        <pitch>
          <step>D</step>
          <octave>5</octave>
          </pitch>
        <duration>2</duration>
        <voice>1</voice>
        <type>eighth</type>
        <stem>down</stem>
        <beam number="1">end</beam>
        </note>
      <note default-x="375.33" default-y="-105.00">
        <grace/>
        <pitch>
          <step>F</step>
          <octave>5</octave>
          </pitch>
        <voice>1</voice>
        <type>eighth</type>
        <stem>up</stem>
        </note>
      <note default-x="407.04" default-y="-110.00">
        <pitch>
          <step>E</step>
          <alter>-1</alter>
          <octave>5</octave>
          </pitch>
        <duration>2</duration>
        <voice>1</voice>
        <type>eighth</type>
        <accidental>flat</accidental>
        <stem>down</stem>
        <beam number="1">begin</beam>
        </note>
      <note default-x="473.53" default-y="-115.00">
        <pitch>
          <step>D</step>
          <octave>5</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>16th</type>
        <stem>down</stem>
        <beam number="1">continue</beam>
        <beam number="2">begin</beam>
        </note>
      <note default-x="515.08" default-y="-120.00">
        <pitch>
          <step>C</step>
          <octave>5</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>16th</type>
        <stem>down</stem>
        <beam number="1">end</beam>
        <beam number="2">end</beam>
        </note>
      <barline location="right">
        <bar-style>light-heavy</bar-style>
        </barline>
      </measure>
    </part>
  </score-partwise>

Humdrum conversion:

**kern  **kern
*part2  *part1
*staff2 *staff1
*clefG2 *clefG2
*k[]    *k[]
*M4/4   *M4/4
=1  =1
*tremolo    *
8ddL    4f
8dd .
8dd 4r
8ddJ    .
*Xtremolo   *
*   *tremolo
8ddL    8fL
*   *Xtremolo
8ddJ    8f
8qqff/  8f
8ee-XL  .
16ddL   8fJ
16ccJJ  .
==  ==
*-  *-
!!!system-decoration: s1,s2

It looks like notes of tremolo - encoded in MuseScore as half note with abbreviation - are placed in the line of tuplet, what is illegal in Humdrum...

craigsapp commented 4 years ago

Fixed with commit https://github.com/rism-ch/verovio/commit/11b99e374c66d1a694fa617d7c00ebfbd11293ec

Now converts correctly:

Screen Shot 2020-06-28 at 5 11 15 PM
**kern  **kern
*part2  *part1
*staff2 *staff1
*clefG2 *clefG2
*k[]    *k[]
*M4/4   *M4/4
=1  =1
*tremolo    *
8ddL    4f
8dd .
8dd 4r
8ddJ    .
*Xtremolo   *
*   *tremolo
8ddL    8fL
8ddJ    8f
8qqff/  .
8ee-XL  8f
16ddL   8fJ
16ccJJ  .
*   *Xtremolo
==  ==
*-  *-
!!!system-decoration: s1,s2
jacekiwaszko1 commented 3 years ago

Similar problem occurs when there's two-note (fingered?) tremolo in one part and a grace note in the other.

Original example:

grace-fingered-tremolo1

MusicXML encoding:

<?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">
  <work>
    <work-title>Title</work-title>
    </work>
  <identification>
    <creator type="composer">Composer</creator>
    <encoding>
      <software>MuseScore 3.5.0</software>
      <encoding-date>2020-09-23</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>5.45808</millimeters>
      <tenths>40</tenths>
      </scaling>
    <page-layout>
      <page-height>2177</page-height>
      <page-width>1539</page-width>
      <page-margins type="both">
        <left-margin>73.0001</left-margin>
        <right-margin>73.0001</right-margin>
        <top-margin>73.0001</top-margin>
        <bottom-margin>146</bottom-margin>
        </page-margins>
      </page-layout>
    <word-font font-family="FreeSerif" font-size="9.3037"/>
    <lyric-font font-family="FreeSerif" font-size="8.9412"/>
    </defaults>
  <part-list>
    <part-group type="start" number="1">
      <group-symbol>bracket</group-symbol>
      </part-group>
    <score-part id="P1">
      <part-name>Violino Primo.</part-name>
      <part-abbreviation>Vn I</part-abbreviation>
      <score-instrument id="P1-I1">
        <instrument-name>Violin</instrument-name>
        </score-instrument>
      <midi-device id="P1-I1" port="1"></midi-device>
      <midi-instrument id="P1-I1">
        <midi-channel>16</midi-channel>
        <midi-program>41</midi-program>
        <volume>78.7402</volume>
        <pan>0</pan>
        </midi-instrument>
      </score-part>
    <part-group type="stop" number="1"/>
    <part-group type="start" number="1">
      <group-symbol>bracket</group-symbol>
      </part-group>
    <score-part id="P2">
      <part-name>Organo</part-name>
      <part-abbreviation>Org.</part-abbreviation>
      <score-instrument id="P2-I1">
        <instrument-name>Organ</instrument-name>
        </score-instrument>
      <midi-device id="P2-I1" port="2"></midi-device>
      <midi-instrument id="P2-I1">
        <midi-channel>9</midi-channel>
        <midi-program>20</midi-program>
        <volume>78.7402</volume>
        <pan>0</pan>
        </midi-instrument>
      </score-part>
    <part-group type="stop" number="1"/>
    </part-list>
  <part id="P1">
    <measure number="1" width="237.17">
      <print>
        <system-layout>
          <system-margins>
            <left-margin>126.31</left-margin>
            <right-margin>1029.53</right-margin>
            </system-margins>
          <top-system-distance>70.00</top-system-distance>
          </system-layout>
        </print>
      <attributes>
        <divisions>4</divisions>
        <key>
          <fifths>0</fifths>
          </key>
        <time>
          <beats>3</beats>
          <beat-type>4</beat-type>
          </time>
        <clef>
          <sign>G</sign>
          <line>2</line>
          </clef>
        </attributes>
      <note default-x="86.63" default-y="-5.00">
        <pitch>
          <step>E</step>
          <octave>5</octave>
          </pitch>
        <duration>4</duration>
        <voice>1</voice>
        <type>quarter</type>
        <stem>down</stem>
        </note>
      <note>
        <rest/>
        <duration>2</duration>
        <voice>1</voice>
        <type>eighth</type>
        </note>
      <note default-x="132.54" default-y="-15.00">
        <pitch>
          <step>C</step>
          <octave>5</octave>
          </pitch>
        <duration>2</duration>
        <voice>1</voice>
        <type>eighth</type>
        <stem>down</stem>
        </note>
      <note default-x="149.96" default-y="-10.00">
        <grace slash="yes"/>
        <pitch>
          <step>D</step>
          <octave>5</octave>
          </pitch>
        <voice>1</voice>
        <type>eighth</type>
        <stem>up</stem>
        </note>
      <note default-x="168.40" default-y="-15.00">
        <pitch>
          <step>C</step>
          <octave>5</octave>
          </pitch>
        <duration>2</duration>
        <voice>1</voice>
        <type>eighth</type>
        <stem>down</stem>
        <beam number="1">begin</beam>
        </note>
      <note default-x="187.73" default-y="-20.00">
        <pitch>
          <step>B</step>
          <octave>4</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>16th</type>
        <stem>down</stem>
        <beam number="1">continue</beam>
        <beam number="2">begin</beam>
        </note>
      <note default-x="203.40" default-y="-15.00">
        <pitch>
          <step>C</step>
          <octave>5</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>16th</type>
        <stem>down</stem>
        <beam number="1">end</beam>
        <beam number="2">end</beam>
        </note>
      <barline location="right">
        <bar-style>light-heavy</bar-style>
        </barline>
      </measure>
    </part>
  <part id="P2">
    <measure number="1" width="237.17">
      <print>
        <staff-layout number="1">
          <staff-distance>65.00</staff-distance>
          </staff-layout>
        </print>
      <attributes>
        <divisions>4</divisions>
        <key>
          <fifths>0</fifths>
          </key>
        <time>
          <beats>3</beats>
          <beat-type>4</beat-type>
          </time>
        <clef>
          <sign>F</sign>
          <line>4</line>
          </clef>
        </attributes>
      <note default-x="86.27" default-y="-95.00">
        <pitch>
          <step>C</step>
          <octave>4</octave>
          </pitch>
        <duration>6</duration>
        <voice>1</voice>
        <type>half</type>
        <dot/>
        <time-modification>
          <actual-notes>2</actual-notes>
          <normal-notes>1</normal-notes>
          </time-modification>
        <stem>down</stem>
        <notations>
          <ornaments>
            <tremolo type="start">1</tremolo>
            </ornaments>
          </notations>
        </note>
      <note default-x="132.18" default-y="-110.00">
        <pitch>
          <step>G</step>
          <octave>3</octave>
          </pitch>
        <duration>6</duration>
        <voice>1</voice>
        <type>half</type>
        <dot/>
        <time-modification>
          <actual-notes>2</actual-notes>
          <normal-notes>1</normal-notes>
          </time-modification>
        <stem>down</stem>
        <notations>
          <ornaments>
            <tremolo type="stop">1</tremolo>
            </ornaments>
          </notations>
        </note>
      <barline location="right">
        <bar-style>light-heavy</bar-style>
        </barline>
      </measure>
    </part>
  </score-partwise>

Humdrum conversion (performed by VHV):

**kern  **kern
*part2  *part1
*staff2 *staff1
*I"Organo   *I"Violino Primo.
*I'Org. *I'Vn I
*clefF4 *clefG2
*k[]    *k[]
*M3/4   *M3/4
=1  =1
*tremolo    *
16cLL   4ee
16G .
16c .
16G .
16c 8r
16G .
16c 8cc
16G .
16c 8qdd/
.   8ccL
16G .
16c 16bL
16GJJ   16ccJJ
*Xtremolo   *
==  ==
*-  *-
!!!system-decoration: [(s1)][(s2)]
craigsapp commented 3 years ago

The correct encoding will be to not place the tremolo note on the grace note line:

**kern  **kern
*part2  *part1
*staff2 *staff1
*I"Organo   *I"Violino Primo.
*I'Org. *I'Vn I
*clefF4 *clefG2
*k[]    *k[]
*M3/4   *M3/4
=1  =1
*tremolo    *
16cLL   4ee
16G .
16c .
16G .
16c 8r
16G .
16c 8cc
16G .
16c 8qdd/
.   8ccL
16G .
16c 16bL
16GJJ   16ccJJ
*Xtremolo   *
==  ==
*-  *-
!!!system-decoration: [(s1)][(s2)]
Screen Shot 2020-09-23 at 7 20 23 AM

This should be an easy fix: placement of the tremolo note should check to see if the line is a grace note line, and if so, progress the the first data line that is not a grace note line.

Also, the converter seems to have halved the duration of the tremolo notes, so the correct conversion should be:

**kern  **kern
*part2  *part1
*staff2 *staff1
*I"Organo   *I"Violino Primo.
*I'Org. *I'Vn I
*clefF4 *clefG2
*k[]    *k[]
*M3/4   *M3/4
=1  =1
*tremolo    *
8cLL    4ee
8G  .
8c  8r
8G  8cc
.   8qdd/
8c  8ccL
8GJJ    16bL
.   16ccJJ
==  ==
*-  *-
!!!system-decoration: [(s1)][(s2)]

Rendering:

Screen Shot 2020-09-23 at 7 24 29 AM

I think the styling in the MusicXML is unspecified. In verovio you can have the beam attached or not:

 <fTrem xml:id="ftrem-L11F1-L17F1" beams="1" unitdur="8">
      <note xml:id="note-L11F1" dots="1" dur="2" oct="4" pname="c" accid.ges="n" />
      <note xml:id="note-L17F1" dots="1" dur="2" oct="3" pname="g" accid.ges="n" />
 </fTrem>

Changing the beam to beam.float:

 <fTrem xml:id="ftrem-L11F1-L17F1" beams.float="1" unitdur="8">
      <note xml:id="note-L11F1" dots="1" dur="2" oct="4" pname="c" accid.ges="n" />
      <note xml:id="note-L17F1" dots="1" dur="2" oct="3" pname="g" accid.ges="n" />
 </fTrem>

which renders as:

Screen Shot 2020-09-23 at 7 30 47 AM

The two visual styles have the same meaning of 8th-note tremolo for the duration of a dotted half note. So a layout parameter for individual tremolos or a layout interpretation would be needed for setting the style of multiple tremolos one way or the other. For 16th-note tremolos, it is more complicated since there can be two regular beams, or two floating beams, or one floating and one regular beam...

Where fTrem means "fingered tremolo" with two notes in the tremolo, and bTrem is a single-note tremolo (meaning "bowed tremolo"). These are the names that string players use. For pianists, these names are confusing since both tremolos use multiple fingers to perform, so otherwise a fingered tremolo would also be called a two-note tremolo.