Skip to content

Commit 488a358

Browse files
rettinghausJojo-Schmitz
authored andcommitted
[MusicXML] export all time signature string components
Backport of musescore#28156
1 parent 79b8587 commit 488a358

File tree

4 files changed

+268
-6
lines changed

4 files changed

+268
-6
lines changed

importexport/musicxml/exportxml.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,14 +2124,15 @@ void ExportMusicXml::timesig(const TimeSig* tsig, int staff)
21242124
const int z = ts.numerator();
21252125
const int n = ts.denominator();
21262126
const QString ns = tsig->numeratorString();
2127+
const QString ds = tsig->denominatorString();
21272128

21282129
_attr.doAttr(_xml, true);
21292130
QString tagName = "time";
21302131
if (st == TimeSigType::FOUR_FOUR)
21312132
tagName += " symbol=\"common\"";
21322133
else if (st == TimeSigType::ALLA_BREVE)
21332134
tagName += " symbol=\"cut\"";
2134-
else if (!ns.isEmpty() && tsig->denominatorString().isEmpty())
2135+
else if (!ns.isEmpty() && ds.isEmpty())
21352136
tagName += " symbol=\"single-number\"";
21362137
if (staff)
21372138
tagName += QString(" number=\"%1\"").arg(staff);
@@ -2140,14 +2141,14 @@ void ExportMusicXml::timesig(const TimeSig* tsig, int staff)
21402141
tagName += color2xml(tsig);
21412142
_xml.stag(tagName);
21422143

2143-
static const QRegExp beats_re("^\\d+(\\+\\d+)+$"); // matches a compound numerator
2144-
if (beats_re.exactMatch(ns))
2145-
// if compound numerator, exported as is
2144+
if (!ns.isEmpty())
21462145
_xml.tag("beats", ns);
21472146
else
2148-
// else fall back and use the numerator as integer
21492147
_xml.tag("beats", z);
2150-
_xml.tag("beat-type", n);
2148+
if (!ds.isEmpty())
2149+
_xml.tag("beat-type", ds);
2150+
else
2151+
_xml.tag("beat-type", n);
21512152
_xml.etag();
21522153
}
21532154

mtest/musicxml/io/testTimesig5.mscx

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<museScore version="3.02">
3+
<Score>
4+
<Division>480</Division>
5+
<showInvisible>1</showInvisible>
6+
<showUnprintable>1</showUnprintable>
7+
<showFrames>1</showFrames>
8+
<showMargins>0</showMargins>
9+
<open>1</open>
10+
<metaTag name="arranger"></metaTag>
11+
<metaTag name="composer">K. Rettinghaus</metaTag>
12+
<metaTag name="copyright"></metaTag>
13+
<metaTag name="creationDate">2025-08-19</metaTag>
14+
<metaTag name="lyricist"></metaTag>
15+
<metaTag name="movementNumber"></metaTag>
16+
<metaTag name="movementTitle"></metaTag>
17+
<metaTag name="source"></metaTag>
18+
<metaTag name="subtitle"></metaTag>
19+
<metaTag name="translator"></metaTag>
20+
<metaTag name="workNumber"></metaTag>
21+
<metaTag name="workTitle">e über pi</metaTag>
22+
<Order id="orchestra">
23+
<name>Orchestra</name>
24+
<instrument id="piano">
25+
<family id="keyboards">Tasteninstrumente</family>
26+
</instrument>
27+
<section id="woodwind" brackets="true" barLineSpan="true" thinBrackets="true">
28+
<family>flutes</family>
29+
<family>oboes</family>
30+
<family>clarinets</family>
31+
<family>saxophones</family>
32+
<family>bassoons</family>
33+
<unsorted group="woodwinds"/>
34+
</section>
35+
<section id="brass" brackets="true" barLineSpan="true" thinBrackets="true">
36+
<family>horns</family>
37+
<family>trumpets</family>
38+
<family>cornets</family>
39+
<family>flugelhorns</family>
40+
<family>trombones</family>
41+
<family>tubas</family>
42+
<unsorted group="brass"/>
43+
</section>
44+
<section id="timpani" brackets="true" barLineSpan="true" thinBrackets="true">
45+
<family>timpani</family>
46+
</section>
47+
<section id="percussion" brackets="true" barLineSpan="true" thinBrackets="true">
48+
<family>keyboard-percussion</family>
49+
<unsorted group="pitched-percussion"/>
50+
<family>drums</family>
51+
<family>unpitched-metal-percussion</family>
52+
<family>unpitched-wooden-percussion</family>
53+
<family>other-percussion</family>
54+
<unsorted group="unpitched-percussion"/>
55+
</section>
56+
<family>keyboards</family>
57+
<family>harps</family>
58+
<family>organs</family>
59+
<family>synths</family>
60+
<unsorted/>
61+
<soloists/>
62+
<section id="voices" brackets="true" barLineSpan="false" thinBrackets="true">
63+
<family>voices</family>
64+
<family>voice-groups</family>
65+
</section>
66+
<section id="strings" brackets="true" barLineSpan="true" thinBrackets="true">
67+
<family>orchestral-strings</family>
68+
</section>
69+
</Order>
70+
<Part id="1">
71+
<Staff id="1">
72+
<StaffType group="pitched">
73+
<name>stdNormal</name>
74+
</StaffType>
75+
<bracket type="1" span="2" col="0" visible="1"/>
76+
<barLineSpan>1</barLineSpan>
77+
</Staff>
78+
<Staff id="2">
79+
<StaffType group="pitched">
80+
<name>stdNormal</name>
81+
</StaffType>
82+
<defaultClef>F</defaultClef>
83+
</Staff>
84+
<trackName>Klavier</trackName>
85+
<Instrument id="piano">
86+
<longName>Klavier</longName>
87+
<shortName>Klav.</shortName>
88+
<trackName>Klavier</trackName>
89+
<minPitchP>21</minPitchP>
90+
<maxPitchP>108</maxPitchP>
91+
<minPitchA>21</minPitchA>
92+
<maxPitchA>108</maxPitchA>
93+
<instrumentId>keyboard.piano</instrumentId>
94+
<clef staff="2">F</clef>
95+
<singleNoteDynamics>0</singleNoteDynamics>
96+
<Channel>
97+
<program value="0"/>
98+
<synti>Fluid</synti>
99+
</Channel>
100+
</Instrument>
101+
</Part>
102+
<Staff id="1">
103+
<Measure>
104+
<voice>
105+
<KeySig>
106+
<concertKey>0</concertKey>
107+
</KeySig>
108+
<TimeSig>
109+
<sigN>2</sigN>
110+
<sigD>4</sigD>
111+
<textN>e</textN>
112+
<textD>π</textD>
113+
<Groups>
114+
<Node pos="4" action="512"/>
115+
<Node pos="8" action="273"/>
116+
<Node pos="12" action="512"/>
117+
</Groups>
118+
</TimeSig>
119+
<Rest>
120+
<durationType>measure</durationType>
121+
<duration>2/4</duration>
122+
</Rest>
123+
</voice>
124+
</Measure>
125+
<Measure>
126+
<voice>
127+
<Rest>
128+
<durationType>measure</durationType>
129+
<duration>2/4</duration>
130+
</Rest>
131+
</voice>
132+
</Measure>
133+
</Staff>
134+
<Staff id="2">
135+
<Measure>
136+
<voice>
137+
<KeySig>
138+
<concertKey>0</concertKey>
139+
</KeySig>
140+
<TimeSig>
141+
<sigN>2</sigN>
142+
<sigD>4</sigD>
143+
<textN>e</textN>
144+
<textD> π</textD>
145+
<Groups>
146+
<Node pos="4" action="512"/>
147+
<Node pos="8" action="273"/>
148+
<Node pos="12" action="512"/>
149+
</Groups>
150+
</TimeSig>
151+
<Rest>
152+
<durationType>measure</durationType>
153+
<duration>2/4</duration>
154+
</Rest>
155+
</voice>
156+
</Measure>
157+
<Measure>
158+
<voice>
159+
<Rest>
160+
<durationType>measure</durationType>
161+
<duration>2/4</duration>
162+
</Rest>
163+
</voice>
164+
</Measure>
165+
</Staff>
166+
</Score>
167+
</museScore>
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
3+
<score-partwise version="4.0">
4+
<work>
5+
<work-title>e über pi</work-title>
6+
</work>
7+
<identification>
8+
<creator type="composer">K. Rettinghaus</creator>
9+
<encoding>
10+
<software>MuseScore 0.7.0</software>
11+
<encoding-date>2007-09-10</encoding-date>
12+
<supports element="accidental" type="yes"/>
13+
<supports element="beam" type="yes"/>
14+
<supports element="print" attribute="new-page" type="no"/>
15+
<supports element="print" attribute="new-system" type="no"/>
16+
<supports element="stem" type="yes"/>
17+
</encoding>
18+
</identification>
19+
<part-list>
20+
<score-part id="P1">
21+
<part-name>Klavier</part-name>
22+
<part-abbreviation>Klav.</part-abbreviation>
23+
<score-instrument id="P1-I1">
24+
<instrument-name>Klavier</instrument-name>
25+
</score-instrument>
26+
<midi-device id="P1-I1" port="1"></midi-device>
27+
<midi-instrument id="P1-I1">
28+
<midi-channel>1</midi-channel>
29+
<midi-program>1</midi-program>
30+
<volume>78.7402</volume>
31+
<pan>0</pan>
32+
</midi-instrument>
33+
</score-part>
34+
</part-list>
35+
<part id="P1">
36+
<measure number="1">
37+
<attributes>
38+
<divisions>1</divisions>
39+
<key>
40+
<fifths>0</fifths>
41+
</key>
42+
<time>
43+
<beats>e</beats>
44+
<beat-type>π</beat-type>
45+
</time>
46+
<staves>2</staves>
47+
<clef number="1">
48+
<sign>G</sign>
49+
<line>2</line>
50+
</clef>
51+
<clef number="2">
52+
<sign>F</sign>
53+
<line>4</line>
54+
</clef>
55+
</attributes>
56+
<note>
57+
<rest measure="yes"/>
58+
<duration>2</duration>
59+
<voice>1</voice>
60+
<staff>1</staff>
61+
</note>
62+
<backup>
63+
<duration>2</duration>
64+
</backup>
65+
<note>
66+
<rest measure="yes"/>
67+
<duration>2</duration>
68+
<voice>5</voice>
69+
<staff>2</staff>
70+
</note>
71+
</measure>
72+
<measure number="2">
73+
<note>
74+
<rest measure="yes"/>
75+
<duration>2</duration>
76+
<voice>1</voice>
77+
<staff>1</staff>
78+
</note>
79+
<backup>
80+
<duration>2</duration>
81+
</backup>
82+
<note>
83+
<rest measure="yes"/>
84+
<duration>2</duration>
85+
<voice>5</voice>
86+
<staff>2</staff>
87+
</note>
88+
<barline location="right">
89+
<bar-style>light-heavy</bar-style>
90+
</barline>
91+
</measure>
92+
</part>
93+
</score-partwise>

mtest/musicxml/io/tst_mxml_io.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ private slots:
332332
void timesig1() { mxmlIoTest("testTimesig1"); }
333333
void timesig3() { mxmlIoTest("testTimesig3"); }
334334
void timesig4() { mxmlIoTest("testTimesig4"); }
335+
void timesig5() { mxmlIoTest("testTimesig5"); }
335336
void titleSwapMu() {mxmlImportTestRef("testTitleSwapMu"); }
336337
void titleSwapSib() { mxmlImportTestRef("testTitleSwapSib"); }
337338
void trackHandling() { mxmlIoTest("testTrackHandling"); }

0 commit comments

Comments
 (0)