Skip to content

Commit

Permalink
Accept non bold tempos, but reject italic and text below the stave
Browse files Browse the repository at this point in the history
Backport of musescore#22632
  • Loading branch information
miiizen authored and Jojo-Schmitz committed May 6, 2024
1 parent 9e24004 commit 644afb3
Show file tree
Hide file tree
Showing 8 changed files with 588 additions and 703 deletions.
9 changes: 6 additions & 3 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3249,7 +3249,7 @@ void MusicXMLParserDirection::direction(const QString& partId,
// Ignore (TBD: print to footer?)
return;
}
else if (isLikelyTempoText()) {
else if (isLikelyTempoText(track)) {
TempoText* tt = new TempoText(_score);
tt->setXmlText(_wordsText + _metroText);
if (_tpoSound > 0 && canAddTempoText(_score->tempomap(), tick.ticks())) {
Expand Down Expand Up @@ -3892,9 +3892,12 @@ bool MusicXMLParserDirection::isLikelyLegallyDownloaded(const Fraction& tick) co
&& _wordsText.contains(QRegularExpression("This music has been legally downloaded\\.\\sDo not photocopy\\."));
}

bool MusicXMLParserDirection::isLikelyTempoText() const
bool MusicXMLParserDirection::isLikelyTempoText(const int track) const
{
if (!preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTINFERTEXTTYPE) || !_wordsText.contains("<b>") || _placement == "below") {
if (!preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTINFERTEXTTYPE)
|| _wordsText.contains("<i>")
|| placement() == "below"
|| track2staff(track) != 0) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion importexport/musicxml/importmxmlpass2.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class MusicXMLParserDirection {
void hideRedundantHeaderText(const Text* inferredText, const std::vector<QString> metaTags);
void textToDynamic(QString& text) const;
bool directionToDynamic();
bool isLikelyTempoText() const;
bool isLikelyTempoText(const int track) const;
bool attemptTempoTextCoercion(const Fraction& tick);
double convertTextToNotes();
void skipLogCurrElem();
Expand Down
Binary file modified mtest/musicxml/io/testInferredTempoText.xml
Binary file not shown.
204 changes: 204 additions & 0 deletions mtest/musicxml/io/testInferredTempoText2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
<?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 4.4.0</software>
<encoding-date>2024-05-01</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>
</identification>
<defaults>
<scaling>
<millimeters>6.99911</millimeters>
<tenths>40</tenths>
</scaling>
<page-layout>
<page-height>1696.94</page-height>
<page-width>1200.48</page-width>
<page-margins type="even">
<left-margin>85.7252</left-margin>
<right-margin>85.7252</right-margin>
<top-margin>85.7252</top-margin>
<bottom-margin>85.7252</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>85.7252</left-margin>
<right-margin>85.7252</right-margin>
<top-margin>85.7252</top-margin>
<bottom-margin>85.7252</bottom-margin>
</page-margins>
</page-layout>
<appearance>
<line-width type="light barline">1.8</line-width>
<line-width type="heavy barline">5.5</line-width>
<line-width type="beam">5</line-width>
<line-width type="bracket">4.5</line-width>
<line-width type="dashes">1</line-width>
<line-width type="enclosure">1</line-width>
<line-width type="ending">1.1</line-width>
<line-width type="extend">1</line-width>
<line-width type="leger">1.6</line-width>
<line-width type="pedal">1.1</line-width>
<line-width type="octave shift">1.1</line-width>
<line-width type="slur middle">2.1</line-width>
<line-width type="slur tip">0.5</line-width>
<line-width type="staff">1.1</line-width>
<line-width type="stem">1</line-width>
<line-width type="tie middle">2.1</line-width>
<line-width type="tie tip">0.5</line-width>
<line-width type="tuplet bracket">1</line-width>
<line-width type="wedge">1.2</line-width>
<note-size type="cue">70</note-size>
<note-size type="grace">70</note-size>
<note-size type="grace-cue">49</note-size>
</appearance>
<music-font font-family="Leland"/>
<word-font font-family="Edwin" font-size="10"/>
<lyric-font font-family="Edwin" font-size="10"/>
</defaults>
<part-list>
<score-part id="P1">
<part-name>Flute</part-name>
<part-abbreviation>Fl.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Flute</instrument-name>
<instrument-sound>wind.flutes.flute</instrument-sound>
</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>
<score-part id="P2">
<part-name>Timpani</part-name>
<part-abbreviation>Timp.</part-abbreviation>
<score-instrument id="P2-I1">
<instrument-name>Timpani</instrument-name>
<instrument-sound>drum.timpani</instrument-sound>
</score-instrument>
<midi-device id="P2-I1" port="1"></midi-device>
<midi-instrument id="P2-I1">
<midi-channel>2</midi-channel>
<midi-program>48</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1" width="940.78">
<print>
<system-layout>
<system-margins>
<left-margin>88.25</left-margin>
<right-margin>-0</right-margin>
</system-margins>
<top-system-distance>70</top-system-distance>
</system-layout>
</print>
<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">
<direction-type>
<words relative-y="10">Slow</words>
</direction-type>
</direction>
<note default-x="494.48" default-y="-10">
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
</measure>
<measure number="2" width="127.86">
<print new-system="yes">
<system-layout>
<system-margins>
<left-margin>62.91</left-margin>
<right-margin>838.26</right-margin>
</system-margins>
<system-distance>220.83</system-distance>
</system-layout>
</print>
<note default-x="69.86" default-y="-10">
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
<part id="P2">
<measure number="1" width="940.78">
<print>
<staff-layout number="1">
<staff-distance>88.33</staff-distance>
</staff-layout>
</print>
<attributes>
<divisions>1</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>F</sign>
<line>4</line>
</clef>
</attributes>
<direction placement="above">
<direction-type>
<words relative-y="10">Use a slow stroke</words>
</direction-type>
</direction>
<note default-x="494.48" default-y="-138.33">
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
</measure>
<measure number="2" width="127.86">
<print new-system="yes">
<staff-layout number="1">
<staff-distance>88.33</staff-distance>
</staff-layout>
</print>
<note default-x="69.86" default-y="-138.33">
<rest measure="yes"/>
<duration>4</duration>
<voice>1</voice>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>

0 comments on commit 644afb3

Please sign in to comment.