rism-digital / verovio

🎵 Music notation engraving library for MEI with MusicXML and Humdrum support and various toolkits (JavaScript, Python)
https://www.verovio.org
GNU Lesser General Public License v3.0
660 stars 181 forks source link

Misplaced harmony if harmony is not mapped to note #687

Closed yeonoson closed 7 years ago

yeonoson commented 7 years ago

When importing from MusicXML, all harmony indication that is not directly belonging to a note is put to the previous note. This might overstrike an existing harmony.

See following screenshot which shows measure 11 + 12 from "Moonlight Sonata Jazz Lead Sheet" rendered by Verovio:

harmony-overstrike

For Moonlight Sonata Jazz Lead Sheet see: Link: https://musescore.com/ericfontainejazz/moonlight-sonata MusicXML: Moonlight_Sonata_Jazz_Lead_Sheet.xml.txt

craigsapp commented 7 years ago

Desired rendering:

screen shot 2017-09-06 at 1 34 33 pm

Current rendering:

screen shot 2017-09-06 at 1 36 08 pm

Extract of MusicXML for the first three chords in measure 11:

      <harmony print-frame="no">
        <root>
          <root-step>C</root-step>
          </root>
        <kind></kind>
        </harmony>
      <harmony print-frame="no">
        <root>
          <root-step>E</root-step>
          </root>
        <kind use-symbols="yes">minor</kind>
        <offset>4</offset>
        </harmony>
      <harmony print-frame="no">
        <root>
          <root-step>A</root-step>
          <root-alter>1</root-alter>
          </root>
        <kind use-symbols="yes">diminished-seventh</kind>
        <offset>8</offset>
        </harmony>

The problem is that the <offset> elements are ignored in the MusicXML-to-MEI converter. These will need to be used to calculate @tstamp on the <harm> labels in MEI. The offset values are in tick units related to the <divisions> portion of <attributes> for the part. In this case divisions = 4, so offset=4 is a quarter note offset from beat 1 (so beat 2), and offset=8 is a half note offset from beat 1 (so beat 3).

Extracted measures 10 and 11 from example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise>
  <identification>
    <rights>https://musescore.com/ericfontainejazz/moonlight-sonata</rights>
    <encoding>
      <software>MuseScore 2.0.1</software>
      <encoding-date>2017-09-06</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>
    <source>http://musescore.com/score/65943</source>
    </identification>
  <defaults>
    <scaling>
      <millimeters>8</millimeters>
      <tenths>40</tenths>
      </scaling>
    <page-layout>
      <page-height>1397</page-height>
      <page-width>1079.5</page-width>
      <page-margins type="both">
        <left-margin>50</left-margin>
        <right-margin>50</right-margin>
        <top-margin>50</top-margin>
        <bottom-margin>100</bottom-margin>
        </page-margins>
      </page-layout>
    <word-font font-family="MuseJazz" font-size="10"/>
    <lyric-font font-family="MuseJazz" font-size="10"/>
    </defaults>
  <credit page="1">
    <credit-words default-x="1029.5" default-y="1242" justify="right" valign="bottom" font-size="12">Ludwig van Beethoven</credit-words>
    </credit>
  <credit page="1">
    <credit-words default-x="539.75" default-y="1347" justify="center" valign="top" font-weight="bold" font-size="28">Moonlight Sonata (leadsheet)</credit-words>
    </credit>
  <credit page="1">
    <credit-words default-x="539.75" default-y="1297" justify="center" valign="top" font-size="14">Piano Sonata no. 14 in C# min, op. 27, no. 2, movt 1</credit-words>
    </credit>
  <credit page="1">
    <credit-words default-x="539.75" default-y="100" justify="center" valign="bottom" font-size="8">https://musescore.com/ericfontainejazz/moonlight-sonata</credit-words>
    </credit>
  <part-list>
    <score-part id="P1">
      <part-name print-object="no">Lead</part-name>
      <score-instrument id="P1-I1">
        <instrument-name>Flute</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>74</midi-program>
        <volume>78.7402</volume>
        <pan>0</pan>
        </midi-instrument>
      </score-part>
    </part-list>
  <part id="P1">
    <measure number="1" width="481.06">
      <print>
        <system-layout>
          <system-margins>
            <left-margin>0.00</left-margin>
            <right-margin>-0.00</right-margin>
            </system-margins>
          <top-system-distance>175.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>
      <harmony print-frame="no">
        <root>
          <root-step>G</root-step>
          </root>
        <kind text="7">dominant</kind>
        </harmony>
      <note default-x="74.99" default-y="-30.00">
        <pitch>
          <step>G</step>
          <octave>4</octave>
          </pitch>
        <duration>12</duration>
        <voice>1</voice>
        <type>half</type>
        <dot/>
        <stem>up</stem>
        </note>
      <note default-x="284.04" default-y="-30.00">
        <pitch>
          <step>G</step>
          <octave>4</octave>
          </pitch>
        <duration>3</duration>
        <voice>1</voice>
        <type>eighth</type>
        <dot/>
        <stem>up</stem>
        <beam number="1">begin</beam>
        </note>
      <note default-x="413.24" default-y="-30.00">
        <pitch>
          <step>G</step>
          <octave>4</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>16th</type>
        <stem>up</stem>
        <beam number="1">end</beam>
        <beam number="2">backward hook</beam>
        </note>
      </measure>
    <measure number="2" width="498.44">
      <harmony print-frame="no">
        <root>
          <root-step>C</root-step>
          </root>
        <kind></kind>
        </harmony>
      <harmony print-frame="no">
        <root>
          <root-step>E</root-step>
          </root>
        <kind use-symbols="yes">minor</kind>
        <offset>4</offset>
        </harmony>
      <harmony print-frame="no">
        <root>
          <root-step>A</root-step>
          <root-alter>1</root-alter>
          </root>
        <kind use-symbols="yes">diminished-seventh</kind>
        <offset>8</offset>
        </harmony>
      <note default-x="12.00" default-y="-30.00">
        <pitch>
          <step>G</step>
          <octave>4</octave>
          </pitch>
        <duration>12</duration>
        <voice>1</voice>
        <type>half</type>
        <dot/>
        <stem>up</stem>
        </note>
      <harmony print-frame="no">
        <root>
          <root-step>F</root-step>
          <root-alter>1</root-alter>
          </root>
        <kind text="7">dominant</kind>
        </harmony>
      <note default-x="368.97" default-y="-35.00">
        <pitch>
          <step>F</step>
          <alter>1</alter>
          <octave>4</octave>
          </pitch>
        <duration>4</duration>
        <voice>1</voice>
        <type>quarter</type>
        <accidental>sharp</accidental>
        <stem>up</stem>
        </note>
      <barline location="right">
        <bar-style>light-heavy</bar-style>
        </barline>
      </measure>
    </part>
  </score-partwise>
yeonoson commented 7 years ago

Wow, that was fast! Looks good now... Thank you very much!

craigsapp commented 7 years ago

New verovio rendering:

screen shot 2017-09-08 at 12 32 29 pm