Skip to content

Commit b7281b8

Browse files
authored
Merge pull request #28156 from rettinghaus/xml/timetext
[MusicXML] export all time signature string components
2 parents df2ae7f + 1c7c234 commit b7281b8

File tree

4 files changed

+273
-6
lines changed

4 files changed

+273
-6
lines changed

src/importexport/musicxml/internal/musicxml/export/exportmusicxml.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,14 +2231,15 @@ void ExportMusicXml::timesig(const TimeSig* tsig)
22312231
const int z = ts.numerator();
22322232
const int n = ts.denominator();
22332233
const String ns = tsig->numeratorString();
2234+
const String ds = tsig->denominatorString();
22342235

22352236
m_attr.doAttr(m_xml, true);
22362237
XmlWriter::Attributes attrs;
22372238
if (st == TimeSigType::FOUR_FOUR) {
22382239
attrs = { { "symbol", "common" } };
22392240
} else if (st == TimeSigType::ALLA_BREVE) {
22402241
attrs = { { "symbol", "cut" } };
2241-
} else if (!ns.empty() && tsig->denominatorString().empty()) {
2242+
} else if (!ns.empty() && ds.empty()) {
22422243
attrs = { { "symbol", "single-number" } };
22432244
}
22442245
if (!tsig->visible()) {
@@ -2249,15 +2250,16 @@ void ExportMusicXml::timesig(const TimeSig* tsig)
22492250

22502251
m_xml.startElement("time", attrs);
22512252

2252-
static const std::regex beats_re("^\\d+(\\+\\d+)+$");
2253-
if (std::regex_match(ns.toStdString(), beats_re)) {
2254-
// if compound numerator, exported as is
2253+
if (!ns.empty()) {
22552254
m_xml.tag("beats", ns);
22562255
} else {
2257-
// else fall back and use the numerator as integer
22582256
m_xml.tag("beats", z);
22592257
}
2260-
m_xml.tag("beat-type", n);
2258+
if (!ds.empty()) {
2259+
m_xml.tag("beat-type", ds);
2260+
} else {
2261+
m_xml.tag("beat-type", n);
2262+
}
22612263
m_xml.endElement();
22622264
}
22632265

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<museScore version="4.50">
3+
<programVersion>4.5.2</programVersion>
4+
<programRevision>ac9d3bc</programRevision>
5+
<Score>
6+
<Division>480</Division>
7+
<showInvisible>1</showInvisible>
8+
<showUnprintable>1</showUnprintable>
9+
<showFrames>1</showFrames>
10+
<showMargins>0</showMargins>
11+
<open>1</open>
12+
<metaTag name="arranger"></metaTag>
13+
<metaTag name="composer">K. Rettinghaus</metaTag>
14+
<metaTag name="copyright"></metaTag>
15+
<metaTag name="creationDate">2025-08-19</metaTag>
16+
<metaTag name="lyricist"></metaTag>
17+
<metaTag name="movementNumber"></metaTag>
18+
<metaTag name="movementTitle"></metaTag>
19+
<metaTag name="source"></metaTag>
20+
<metaTag name="subtitle"></metaTag>
21+
<metaTag name="translator"></metaTag>
22+
<metaTag name="workNumber"></metaTag>
23+
<metaTag name="workTitle">e über pi</metaTag>
24+
<Order id="orchestra">
25+
<name>Orchestra</name>
26+
<instrument id="piano">
27+
<family id="keyboards">Tasteninstrumente</family>
28+
</instrument>
29+
<section id="woodwind" brackets="true" barLineSpan="true" thinBrackets="true">
30+
<family>flutes</family>
31+
<family>oboes</family>
32+
<family>clarinets</family>
33+
<family>saxophones</family>
34+
<family>bassoons</family>
35+
<unsorted group="woodwinds"/>
36+
</section>
37+
<section id="brass" brackets="true" barLineSpan="true" thinBrackets="true">
38+
<family>horns</family>
39+
<family>trumpets</family>
40+
<family>cornets</family>
41+
<family>flugelhorns</family>
42+
<family>trombones</family>
43+
<family>tubas</family>
44+
<unsorted group="brass"/>
45+
</section>
46+
<section id="timpani" brackets="true" barLineSpan="true" thinBrackets="true">
47+
<family>timpani</family>
48+
</section>
49+
<section id="percussion" brackets="true" barLineSpan="true" thinBrackets="true">
50+
<family>keyboard-percussion</family>
51+
<unsorted group="pitched-percussion"/>
52+
<family>drums</family>
53+
<family>unpitched-metal-percussion</family>
54+
<family>unpitched-wooden-percussion</family>
55+
<family>other-percussion</family>
56+
<unsorted group="unpitched-percussion"/>
57+
</section>
58+
<family>keyboards</family>
59+
<family>harps</family>
60+
<family>organs</family>
61+
<family>synths</family>
62+
<unsorted/>
63+
<soloists/>
64+
<section id="voices" brackets="true" barLineSpan="false" thinBrackets="true">
65+
<family>voices</family>
66+
<family>voice-groups</family>
67+
</section>
68+
<section id="strings" brackets="true" barLineSpan="true" thinBrackets="true">
69+
<family>orchestral-strings</family>
70+
</section>
71+
</Order>
72+
<Part id="1">
73+
<Staff id="1">
74+
<StaffType group="pitched">
75+
<name>stdNormal</name>
76+
</StaffType>
77+
<bracket type="1" span="2" col="0" visible="1"/>
78+
<barLineSpan>1</barLineSpan>
79+
</Staff>
80+
<Staff id="2">
81+
<StaffType group="pitched">
82+
<name>stdNormal</name>
83+
</StaffType>
84+
<defaultClef>F</defaultClef>
85+
</Staff>
86+
<trackName>Klavier</trackName>
87+
<Instrument id="piano">
88+
<longName>Klavier</longName>
89+
<shortName>Klav.</shortName>
90+
<trackName>Klavier</trackName>
91+
<minPitchP>21</minPitchP>
92+
<maxPitchP>108</maxPitchP>
93+
<minPitchA>21</minPitchA>
94+
<maxPitchA>108</maxPitchA>
95+
<instrumentId>keyboard.piano</instrumentId>
96+
<clef staff="2">F</clef>
97+
<singleNoteDynamics>0</singleNoteDynamics>
98+
<Channel>
99+
<program value="0"/>
100+
<synti>Fluid</synti>
101+
</Channel>
102+
</Instrument>
103+
</Part>
104+
<Staff id="1">
105+
<Measure>
106+
<voice>
107+
<KeySig>
108+
<concertKey>0</concertKey>
109+
</KeySig>
110+
<TimeSig>
111+
<sigN>2</sigN>
112+
<sigD>4</sigD>
113+
<textN>e</textN>
114+
<textD>π</textD>
115+
<Groups>
116+
<Node pos="4" action="512"/>
117+
<Node pos="8" action="273"/>
118+
<Node pos="12" action="512"/>
119+
</Groups>
120+
</TimeSig>
121+
<Rest>
122+
<durationType>measure</durationType>
123+
<duration>2/4</duration>
124+
</Rest>
125+
</voice>
126+
</Measure>
127+
<Measure>
128+
<voice>
129+
<Rest>
130+
<durationType>measure</durationType>
131+
<duration>2/4</duration>
132+
</Rest>
133+
</voice>
134+
</Measure>
135+
</Staff>
136+
<Staff id="2">
137+
<Measure>
138+
<voice>
139+
<KeySig>
140+
<concertKey>0</concertKey>
141+
</KeySig>
142+
<TimeSig>
143+
<sigN>2</sigN>
144+
<sigD>4</sigD>
145+
<textN>e</textN>
146+
<textD> π</textD>
147+
<Groups>
148+
<Node pos="4" action="512"/>
149+
<Node pos="8" action="273"/>
150+
<Node pos="12" action="512"/>
151+
</Groups>
152+
</TimeSig>
153+
<Rest>
154+
<durationType>measure</durationType>
155+
<duration>2/4</duration>
156+
</Rest>
157+
</voice>
158+
</Measure>
159+
<Measure>
160+
<voice>
161+
<Rest>
162+
<durationType>measure</durationType>
163+
<duration>2/4</duration>
164+
</Rest>
165+
</voice>
166+
</Measure>
167+
</Staff>
168+
</Score>
169+
</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>

src/importexport/musicxml/tests/musicxml_tests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,9 @@ TEST_F(MusicXml_Tests, timesig3) {
12481248
TEST_F(MusicXml_Tests, timesig4) {
12491249
musicXmlIoTest("testTimesig4");
12501250
}
1251+
TEST_F(MusicXml_Tests, timesig5) {
1252+
musicXmlMscxExportTestRef("testTimesig5");
1253+
}
12511254
TEST_F(MusicXml_Tests, timeTick) {
12521255
musicXmlImportTestRef("testTimeTick");
12531256
}

0 commit comments

Comments
 (0)