Skip to content

Commit

Permalink
Fix GH#25048: Export Tempo as system text in MusicXML
Browse files Browse the repository at this point in the history
Backport of musescore#25312
  • Loading branch information
rettinghaus authored and Jojo-Schmitz committed Nov 20, 2024
1 parent 69a0e68 commit 20adb41
Show file tree
Hide file tree
Showing 23 changed files with 219 additions and 59 deletions.
5 changes: 4 additions & 1 deletion importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4616,7 +4616,10 @@ void ExportMusicXml::tempoText(TempoText const* const text, int staff)
qPrintable(text->xmlText()));
*/
_attr.doAttr(_xml, false);
_xml.stag(QString("direction placement=\"%1\"").arg((text->placement() == Placement::BELOW ) ? "below" : "above"));
QString tempoAttrs = QString("direction placement=\"%1\"").arg(text->placement() == Placement::BELOW ? "below" : "above");
if (text->systemFlag())
tempoAttrs += QString(" system=\"%1\"").arg(text->isLinked() ? "also-top" : "only-top");
_xml.stag(tempoAttrs);
wordsMetronome(_xml, _score, text, offset);

if (staff)
Expand Down
13 changes: 10 additions & 3 deletions libmscore/scoreElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static void changeProperty(ScoreElement* e, Pid t, const QVariant& st, PropertyF
static void changeProperties(ScoreElement* e, Pid t, const QVariant& st, PropertyFlags ps)
{
if (propertyLink(t)) {
for (ScoreElement* ee : e->linkList())
for (ScoreElement*& ee : e->linkList())
changeProperty(ee, t, st, ps);
}
else
Expand Down Expand Up @@ -580,11 +580,18 @@ void ScoreElement::unlink()
/// linked to this element
//---------------------------------------------------------

bool ScoreElement::isLinked(ScoreElement* se)
bool ScoreElement::isLinked(ScoreElement* se) const
{
return se != this && _links && _links->contains(se);
if (se == this || !_links) {
return false;
}

if (se == nullptr) {
return !_links->empty() && _links->mainElement() != this;
}

return _links->contains(se); }

//---------------------------------------------------------
// undoUnlink
//---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion libmscore/scoreElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class ScoreElement {

void linkTo(ScoreElement*);
void unlink();
bool isLinked(ScoreElement*);
bool isLinked(ScoreElement* se = nullptr) const;

virtual void undoUnlink();
int lid() const { return _links ? _links->lid() : 0; }
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testClefs2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<line>4</line>
</clef>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no">
<beat-unit>quarter</beat-unit>
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testColorExport_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</root>
<kind text="7">dominant</kind>
</harmony>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no" color="#942193">
<beat-unit>quarter</beat-unit>
Expand Down
4 changes: 2 additions & 2 deletions mtest/musicxml/io/testDirections2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<line>2</line>
</clef>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<words font-weight="bold" font-size="12">Lento</words>
</direction-type>
Expand All @@ -95,7 +95,7 @@
<duration>4</duration>
<voice>1</voice>
</note>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<words font-weight="bold" font-size="12">Andante</words>
</direction-type>
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testInvalidLayout_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<multiple-rest>3</multiple-rest>
</measure-style>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no">
<beat-unit>quarter</beat-unit>
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testInvisibleDirection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<line>2</line>
</clef>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no" print-object="no">
<beat-unit>quarter</beat-unit>
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testSound1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<line>2</line>
</clef>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no" print-object="no">
<beat-unit>quarter</beat-unit>
Expand Down
150 changes: 150 additions & 0 deletions mtest/musicxml/io/testSound1_ref.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?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">
<identification>
<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>Music</part-name>
<score-instrument id="P1-I1">
<instrument-name></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>1</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<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>
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no" print-object="no">
<beat-unit>quarter</beat-unit>
<per-minute>60</per-minute>
</metronome>
</direction-type>
<sound tempo="60"/>
</direction>
<note>
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
</note>
<note>
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
</note>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
</note>
<note>
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
</note>
</measure>
<measure number="2">
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
</note>
<note>
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
</note>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
</note>
<note>
<pitch>
<step>D</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
</note>
</measure>
<measure number="3">
<note>
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>whole</type>
</note>
</measure>
</part>
</score-partwise>
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testSound2_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<line>2</line>
</clef>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no" print-object="no">
<beat-unit>quarter</beat-unit>
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testSwing_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<octave-change>1</octave-change>
</transpose>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no">
<beat-unit>quarter</beat-unit>
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testSystemDirection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
</measure>
<measure number="4">
<print new-system="yes"/>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<words font-weight="bold" font-size="12">Largo</words>
</direction-type>
Expand Down
8 changes: 4 additions & 4 deletions mtest/musicxml/io/testTempo1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<line>2</line>
</clef>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<words font-weight="bold" font-size="12">Largo </words>
</direction-type>
Expand Down Expand Up @@ -145,7 +145,7 @@
</note>
</measure>
<measure number="3">
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<words font-weight="bold" font-size="12">Andante</words>
</direction-type>
Expand Down Expand Up @@ -235,13 +235,13 @@
</note>
</measure>
<measure number="5">
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<words font-weight="bold" font-size="12">Vivace</words>
</direction-type>
<sound tempo="120"/>
</direction>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="yes">
<beat-unit>quarter</beat-unit>
Expand Down
6 changes: 3 additions & 3 deletions mtest/musicxml/io/testTempo2_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<line>2</line>
</clef>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no">
<beat-unit>quarter</beat-unit>
Expand Down Expand Up @@ -100,7 +100,7 @@
</note>
</measure>
<measure number="2">
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no">
<beat-unit>quarter</beat-unit>
Expand Down Expand Up @@ -152,7 +152,7 @@
</note>
</measure>
<measure number="3">
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no">
<beat-unit>half</beat-unit>
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testTempo3_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<line>2</line>
</clef>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no">
<beat-unit>half</beat-unit>
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/testTempo4_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<line>2</line>
</clef>
</attributes>
<direction placement="above">
<direction placement="above" system="only-top">
<direction-type>
<metronome parentheses="no">
<beat-unit>quarter</beat-unit>
Expand Down
Loading

0 comments on commit 20adb41

Please sign in to comment.