Skip to content

Commit

Permalink
Fix #329060, fix #48251: [MusicXML export] decimals in metronome mark…
Browse files Browse the repository at this point in the history
…ings get separated
  • Loading branch information
Jojo-Schmitz committed Mar 14, 2023
1 parent c29ade4 commit 62588b4
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/importexport/musicxml/internal/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4183,7 +4183,8 @@ static bool findMetronome(const std::list<TextFragment>& list,
// now determine what is to the right of the equals sign
// must have either a (dotted) note or a number at start of s4
int len3 = 0;
QRegularExpression numberRegEx("\\d+");
// One or more digits, optionally followed by a single dot or comma and one or more digits
QRegularExpression numberRegEx("\\d+([,\\.]{1}\\d+)?");
int pos3 = TempoText::findTempoDuration(s4, len3, dur);
if (pos3 == -1) {
// did not find note, try to find a number
Expand Down
127 changes: 127 additions & 0 deletions src/importexport/musicxml/tests/data/testTempo6.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?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-number>MuseScore testfile</work-number>
<work-title>Tempo 6</work-title>
</work>
<identification>
<creator type="composer">Leon Vinken</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>Piano</part-name>
<part-abbreviation>Pno.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Piano</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">
<direction-type>
<metronome parentheses="no">
<beat-unit>quarter</beat-unit>
<per-minute>85</per-minute>
</metronome>
</direction-type>
<sound tempo="85"/>
</direction>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>whole</type>
<lyric number="1">
<syllabic>single</syllabic>
<text>none</text>
</lyric>
</note>
</measure>
<measure number="2">
<direction placement="above">
<direction-type>
<metronome parentheses="no">
<beat-unit>quarter</beat-unit>
<per-minute>85.10</per-minute>
</metronome>
</direction-type>
<sound tempo="85.1"/>
</direction>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>whole</type>
<lyric number="1">
<syllabic>single</syllabic>
<text>dot</text>
</lyric>
</note>
</measure>
<measure number="3">
<direction placement="above">
<direction-type>
<metronome parentheses="no">
<beat-unit>quarter</beat-unit>
<per-minute>85,10</per-minute>
</metronome>
</direction-type>
<sound tempo="85.1"/>
</direction>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>whole</type>
<lyric number="1">
<syllabic>single</syllabic>
<text>comma</text>
</lyric>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
3 changes: 3 additions & 0 deletions src/importexport/musicxml/tests/musicxml_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,9 @@ TEST_F(Musicxml_Tests, tempo4) {
TEST_F(Musicxml_Tests, tempo5) {
mxmlIoTest("testTempo5");
}
TEST_F(Musicxml_Tests, tempo6) {
mxmlIoTest("testTempo6");
}
TEST_F(Musicxml_Tests, tempoOverlap) {
mxmlIoTestRef("testTempoOverlap");
}
Expand Down

0 comments on commit 62588b4

Please sign in to comment.