MusicXML import: Lyrics extender goes on for too long

Open
#35,750 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
desktop

Research direction

Start in importmusicxmlpass2.cpp, in MusicXmlLyricsExtend::setExtend, where pending extenders are ended only for lyrics matching the same verse, staff and placement. Also check how a lyric holding only extend type="stop" is skipped. Reproduce by importing the attached MusicXML and confirming the extender of "Ah," stops at the second-voice "my" rather than running into bar 2. Done when the sample imports as expected and an explicit stop extender is honoured.

Written by the indexing model from the issue text.

Description

community MusicXML

Steps to reproduce

  1. Import the MusicXML below.

Expected results:

The "Ah,__" should stop at the note where the second voice has the "my". It should not extend beyond the first bar.
There's a <lyric number="1" placement="above"><extend type="stop"/></lyric> in the code where it should stop.

new-crop

Actual results

The lyrics extender keeps going, into the next bar. It only stops at the next "above" lyric which can be arbitrarily far away.
The <extend type="stop"/> is ignored.

old-crop

MusicXML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="4.0">
  <part-list>
    <score-part id="P1"><part-name>Soprano</part-name></score-part>
  </part-list>
  <part id="P1">
    <!-- Divided: the upper voice holds "Ah," (above the stave, its own words)
         while the lower voice sings "I hung my" (below). -->
    <measure number="1">
      <attributes>
        <divisions>1</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><pitch><step>E</step><octave>5</octave></pitch><duration>2</duration><voice>1</voice><type>half</type><stem>up</stem>
        <notations><slur type="start" number="1"/></notations>
        <lyric number="1" placement="above"><syllabic>single</syllabic><text>Ah,</text><extend type="start"/></lyric>
      </note>
      <note><pitch><step>D</step><octave>5</octave></pitch><duration>2</duration><voice>1</voice><type>half</type><stem>up</stem>
        <notations><slur type="stop" number="1"/></notations>
        <lyric number="1" placement="above"><extend type="stop"/></lyric>
      </note>
      <backup><duration>4</duration></backup>
      <note><pitch><step>C</step><octave>5</octave></pitch><duration>1</duration><voice>2</voice><type>quarter</type><stem>down</stem>
        <lyric number="1"><syllabic>single</syllabic><text>I</text></lyric>
      </note>
      <note><pitch><step>B</step><octave>4</octave></pitch><duration>1</duration><voice>2</voice><type>quarter</type><stem>down</stem>
        <lyric number="1"><syllabic>single</syllabic><text>hung</text></lyric>
      </note>
      <note><pitch><step>A</step><octave>4</octave></pitch><duration>2</duration><voice>2</voice><type>half</type><stem>down</stem>
        <lyric number="1"><syllabic>single</syllabic><text>my</text></lyric>
      </note>
    </measure>
    <!-- Together again: one voice, the shared words below the stave.
         The upper voice's next syllable ("head.") should end its extender. -->
    <measure number="2">
      <note><pitch><step>G</step><octave>4</octave></pitch><duration>2</duration><voice>1</voice><type>half</type>
        <lyric number="1"><syllabic>single</syllabic><text>head.</text></lyric>
      </note>
      <note><pitch><step>G</step><octave>4</octave></pitch><duration>2</duration><voice>1</voice><type>half</type>
        <lyric number="1"><syllabic>single</syllabic><text>So</text></lyric>
      </note>
    </measure>
    <!-- Divided again: upper voice "Ah" above, lower voice "one by" below.
         MuseScore 4.7.6 ends the extender of bar 1's "Ah," only here. -->
    <measure number="3">
      <note><pitch><step>E</step><octave>5</octave></pitch><duration>4</duration><voice>1</voice><type>whole</type><stem>up</stem>
        <lyric number="1" placement="above"><syllabic>single</syllabic><text>Ah</text></lyric>
      </note>
      <backup><duration>4</duration></backup>
      <note><pitch><step>C</step><octave>5</octave></pitch><duration>2</duration><voice>2</voice><type>half</type><stem>down</stem>
        <lyric number="1"><syllabic>single</syllabic><text>one</text></lyric>
      </note>
      <note><pitch><step>B</step><octave>4</octave></pitch><duration>2</duration><voice>2</voice><type>half</type><stem>down</stem>
        <lyric number="1"><syllabic>single</syllabic><text>by</text></lyric>
      </note>
    </measure>
    <measure number="4">
      <note><pitch><step>A</step><octave>4</octave></pitch><duration>4</duration><voice>1</voice><type>whole</type>
        <lyric number="1"><syllabic>single</syllabic><text>one.</text></lyric>
      </note>
      <barline location="right"><bar-style>light-heavy</bar-style></barline>
    </measure>
  </part>
</score-partwise>

MuseScore version

4.7.7


Cause

MusicXmlLyricsExtend::setExtend (importmusicxmlpass2.cpp) ends a pending extender only for a lyric of the same verse on the same staff with the same placement (or at a rest on the same track, or at the end of the part). A lyric of the same verse in the same voice, placed on the other side of the stave, doesn't end it. Also, a <lyric> holding only <extend type="stop"/> is skipped ("no further action required"), so the explicit stop has no effect.

Suggested fix

Also end the extenders of the same track and verse, whatever their placement:

if ((verse == -1 && par->track() == track)
    || (l->verse() == verse && par->track() == track)
    || (l->verse() == verse && track2staff(par->track()) == track2staff(track) && prevAddedLyrics
        && prevAddedLyrics->placement() == l->placement())) {

With this change the attached file imports as expected. Honouring <extend type="stop"/> would fix it as well.

Dominant language
C++
Stars
15.5k
Forks
3.5k
Avg merge
2d 19h
Merged PRs (30d)
124

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from musescore/MuseScore

All issues in musescore/MuseScore

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.