Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,18 @@ static Fraction lastChordTicks(const Segment* s, const Fraction& tick, const tra
// called when lyric (with or without "extend") or note with "extend type=stop" is found
// // note that no == -1 means all lyrics in this *track*

void MusicXmlLyricsExtend::setExtend(const int no, const track_idx_t track, const Fraction& tick)
void MusicXmlLyricsExtend::setExtend(const int no, const track_idx_t track, const Fraction& tick, const Lyrics* prevAddedLyrics = nullptr)
{
std::vector<Lyrics*> list;
for (Lyrics* l : m_lyrics) {
const EngravingItem* el = l->parentItem();
if (el->type() == ElementType::CHORD || el->type() == ElementType::REST) {
const ChordRest* par = static_cast<const ChordRest*>(el);
// no = -1: stop all extends on this track
// otherwise, stop all extends in the stave with the same no and placement
if ((no == -1 && par->track() == track)
|| (l->no() == no && track2staff(par->track()) == track2staff(track))) {
|| (l->no() == no && track2staff(par->track()) == track2staff(track) && prevAddedLyrics
&& prevAddedLyrics->placement() == l->placement())) {
Fraction lct = lastChordTicks(l->segment(), tick, track);
if (lct > Fraction(0, 1)) {
// set lyric tick to the total length from the lyric note
Expand Down Expand Up @@ -850,7 +853,7 @@ static void addLyric(MxmlLogger* logger, const XmlStreamReader* const xmlreader,
} else {
l->setNo(lyricNo);
cr->add(l);
extendedLyrics.setExtend(lyricNo, cr->track(), cr->tick());
extendedLyrics.setExtend(lyricNo, cr->track(), cr->tick(), l);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class MusicXmlLyricsExtend
MusicXmlLyricsExtend() {}
void init();
void addLyric(Lyrics* const lyric);
void setExtend(const int no, const track_idx_t track, const Fraction& tick);
void setExtend(const int no, const track_idx_t track, const Fraction& tick, const Lyrics* prevAddedLyrics);

private:
std::set<Lyrics*> m_lyrics;
Expand Down
287 changes: 287 additions & 0 deletions src/importexport/musicxml/tests/data/testLyricExtension2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
<?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">
<work>
<work-title>Untitled score</work-title>
</work>
<identification>
<creator type="composer">Composer / arranger</creator>
<encoding>
<software>MuseScore 0.7.0</software>
<encoding-date>2007-09-10</encoding-date>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="print" attribute="new-page" type="no"/>
<supports element="print" attribute="new-system" type="no"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name>Tenor</part-name>
<part-abbreviation>T.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Tenor</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>53</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>2</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
<clef-octave-change>-1</clef-octave-change>
</clef>
</attributes>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<tie type="start"/>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<notations>
<tied type="start"/>
</notations>
<lyric number="1">
<syllabic>single</syllabic>
<text>Ooh</text>
<extend/>
</lyric>
</note>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<tie type="stop"/>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<notations>
<tied type="stop"/>
</notations>
</note>
<note>
<rest/>
<duration>2</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<backup>
<duration>8</duration>
</backup>
<note>
<rest/>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
</note>
<note>
<pitch>
<step>B</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">begin</beam>
<lyric number="2">
<syllabic>single</syllabic>
<text>Ahh</text>
<extend/>
</lyric>
</note>
<note>
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">continue</beam>
</note>
<note>
<pitch>
<step>B</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">end</beam>
</note>
<note>
<pitch>
<step>A</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">begin</beam>
</note>
<note>
<pitch>
<step>B</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">end</beam>
</note>
<note>
<rest/>
<duration>2</duration>
<voice>2</voice>
<type>quarter</type>
</note>
</measure>
<measure number="2">
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<tie type="start"/>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<notations>
<tied type="start"/>
</notations>
<lyric number="1" placement="above">
<syllabic>single</syllabic>
<text>Ooh</text>
<extend/>
</lyric>
</note>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<tie type="stop"/>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<notations>
<tied type="stop"/>
</notations>
</note>
<note>
<rest/>
<duration>2</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<backup>
<duration>8</duration>
</backup>
<note>
<rest/>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
</note>
<note>
<pitch>
<step>B</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">begin</beam>
<lyric number="1">
<syllabic>single</syllabic>
<text>Ahh</text>
<extend/>
</lyric>
</note>
<note>
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">continue</beam>
</note>
<note>
<pitch>
<step>B</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">end</beam>
</note>
<note>
<pitch>
<step>A</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">begin</beam>
</note>
<note>
<pitch>
<step>B</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<voice>2</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">end</beam>
</note>
<note>
<rest/>
<duration>2</duration>
<voice>2</voice>
<type>quarter</type>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
Loading