Skip to content

Commit

Permalink
Infer sticking from lyrics
Browse files Browse the repository at this point in the history
Backport of musescore#24065
  • Loading branch information
miiizen authored and Jojo-Schmitz committed Aug 18, 2024
1 parent 81ea8a1 commit ef77e66
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 19 deletions.
15 changes: 2 additions & 13 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3331,10 +3331,9 @@ void MusicXMLParserDirection::direction(const QString& partId,
else if (isLikelySticking() && isPercussionStaff) {
Sticking* sticking = new Sticking(_score);
sticking->setXmlText(_wordsText);
if (!qFuzzyIsNull(_relativeX) || !qFuzzyIsNull(_relativeY)) {
if (!qFuzzyIsNull(_relativeX)) {
QPointF offset = sticking->offset();
offset.setX(!qFuzzyIsNull(_relativeX) ? _relativeX : sticking->offset().x());
offset.setY(!qFuzzyIsNull(_relativeY) ? _relativeY : sticking->offset().y());
offset.setX(_relativeX);
sticking->setOffset(offset);
sticking->setPropertyFlags(Pid::OFFSET, PropertyFlags::UNSTYLED);
}
Expand Down Expand Up @@ -3609,24 +3608,14 @@ void MusicXMLParserDirection::directionType(QList<MusicXmlSpannerDesc>& starts,
// Prevent multi-word directions from overwriting y-values.
bool hasDefaultXCandidate = false;
bool hasRelativeXCandidate = false;
bool hasDefaultYCandidate = false;
bool hasRelativeYCandidate = false;
qreal defaultXCandidate = _e.attributes().value("default-x").toDouble(&hasDefaultXCandidate) * -0.1;
qreal defaultYCandidate = _e.attributes().value("default-y").toDouble(&hasDefaultYCandidate) * -0.1;
qreal relativeXCandidate =_e.attributes().value("relative-x").toDouble(&hasRelativeXCandidate) * -0.1;
qreal relativeYCandidate =_e.attributes().value("relative-y").toDouble(&hasRelativeYCandidate) * -0.1;
if (hasDefaultXCandidate && !_hasDefaultX)
_defaultY = defaultXCandidate;
if (hasRelativeXCandidate && !_hasRelativeX)
_relativeX = relativeXCandidate;
_hasDefaultX |= hasDefaultXCandidate;
_hasRelativeX |= hasRelativeXCandidate;
if (hasDefaultYCandidate && !_hasDefaultY)
_defaultY = defaultYCandidate;
if (hasRelativeYCandidate && !_hasRelativeY)
_relativeY = relativeYCandidate;
_hasDefaultY |= hasDefaultYCandidate;
_hasRelativeY |= hasRelativeYCandidate;
_isBold &= _e.attributes().value("font-weight").toString() == "bold";
_visible = _e.attributes().value("print-object").toString() != "no";
QString number = _e.attributes().value("number").toString();
Expand Down
Binary file added mtest/musicxml/io/testStickingLyrics.xml
Binary file not shown.
232 changes: 232 additions & 0 deletions mtest/musicxml/io/testStickingLyrics_ref.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="3.20">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<pageWidth>8.50197</pageWidth>
<pageHeight>11.003</pageHeight>
<pagePrintableWidth>7.50197</pagePrintableWidth>
<pageEvenLeftMargin>0.5</pageEvenLeftMargin>
<pageOddLeftMargin>0.5</pageOddLeftMargin>
<pageEvenTopMargin>0.5</pageEvenTopMargin>
<pageEvenBottomMargin>0.5</pageEvenBottomMargin>
<pageOddTopMargin>0.5</pageOddTopMargin>
<pageOddBottomMargin>0.5</pageOddBottomMargin>
<pageTwosided>0</pageTwosided>
<minSystemDistance>12</minSystemDistance>
<barWidth>0.15625</barWidth>
<endBarWidth>0.5</endBarWidth>
<stemWidth>0.125</stemWidth>
<staffLineWidth>0.125</staffLineWidth>
<ledgerLineWidth>0.15625</ledgerLineWidth>
<smallNoteMag>0.75</smallNoteMag>
<graceNoteMag>0.6</graceNoteMag>
<concertPitch>1</concertPitch>
<slurEndWidth>0.0625</slurEndWidth>
<slurMidWidth>0.21875</slurMidWidth>
<tieEndWidth>0.0625</tieEndWidth>
<tieMidWidth>0.21875</tieMidWidth>
<Spatium>1.75</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer"></metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Snare Drum</trackName>
<Instrument>
<longName>Snare Drum</longName>
<shortName>S. D.</shortName>
<trackName>Marching Snare Drums [5 lines]</trackName>
<Articulation>
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>150</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzatoStaccato">
<velocity>150</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoStaccato">
<velocity>120</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoTenuto">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="0"/>
<controller ctrl="10" value="63"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
</VBox>
<Measure>
<voice>
<Clef>
<concertClefType>PERC</concertClefType>
<transposingClefType>PERC</transposingClefType>
</Clef>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Sticking>
<text>Rlr</text>
</Sticking>
<Beam>
<StemDirection>down</StemDirection>
<l1>19</l1>
<l2>17</l2>
</Beam>
<Chord>
<BeamMode>begin</BeamMode>
<durationType>eighth</durationType>
<Articulation>
<subtype>articAccentAbove</subtype>
</Articulation>
<Note>
<pitch>38</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Sticking>
<text>R</text>
</Sticking>
<Chord>
<BeamMode>mid</BeamMode>
<durationType>eighth</durationType>
<Note>
<pitch>38</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Sticking>
<text>l</text>
</Sticking>
<Chord>
<BeamMode>mid</BeamMode>
<durationType>eighth</durationType>
<Articulation>
<subtype>articAccentAbove</subtype>
</Articulation>
<Note>
<pitch>48</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Sticking>
<text>r</text>
</Sticking>
<Chord>
<durationType>eighth</durationType>
<Note>
<pitch>48</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Sticking>
<text>B</text>
</Sticking>
<Beam>
<StemDirection>down</StemDirection>
<l1>38</l1>
<l2>42</l2>
</Beam>
<Chord>
<BeamMode>begin</BeamMode>
<durationType>eighth</durationType>
<Note>
<pitch>38</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Sticking>
<text>lr</text>
</Sticking>
<Chord>
<BeamMode>mid</BeamMode>
<durationType>eighth</durationType>
<Articulation>
<subtype>articAccentAbove</subtype>
</Articulation>
<Note>
<pitch>38</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Sticking>
<text>B</text>
</Sticking>
<Chord>
<BeamMode>mid</BeamMode>
<durationType>eighth</durationType>
<Note>
<pitch>43</pitch>
<tpc>15</tpc>
</Note>
</Chord>
<Sticking>
<text>l</text>
</Sticking>
<Chord>
<durationType>eighth</durationType>
<Note>
<pitch>43</pitch>
<tpc>15</tpc>
</Note>
</Chord>
<BarLine>
<subtype>end</subtype>
</BarLine>
</voice>
</Measure>
</Staff>
</Score>
</museScore>
6 changes: 0 additions & 6 deletions mtest/musicxml/io/testSticking_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@
<Measure>
<voice>
<Sticking>
<offset x="-2" y="2"/>
<text>L</text>
</Sticking>
<Sticking>
Expand Down Expand Up @@ -506,7 +505,6 @@
</Note>
</Chord>
<Sticking>
<offset x="-2" y="2"/>
<text>L</text>
</Sticking>
<Sticking>
Expand Down Expand Up @@ -562,19 +560,15 @@
<Measure>
<voice>
<Sticking>
<offset x="-5" y="2"/>
<text>l</text>
</Sticking>
<Sticking>
<offset x="-4" y="2"/>
<text>r</text>
</Sticking>
<Sticking>
<offset x="-2.5" y="2"/>
<text>l</text>
</Sticking>
<Sticking>
<offset x="-1" y="2"/>
<text>r</text>
</Sticking>
<Sticking>
Expand Down

0 comments on commit ef77e66

Please sign in to comment.