Skip to content

Commit 21cf424

Browse files
Merge pull request #8793 from lvinken/321960-musicxml-beat-unit-master
Fix #321960: [MusicXML export] Tempo beating at the whole does not ex…
2 parents f2d4a51 + 52f8a34 commit 21cf424

File tree

3 files changed

+297
-22
lines changed

3 files changed

+297
-22
lines changed

src/importexport/musicxml/internal/musicxml/exportxml.cpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4099,25 +4099,6 @@ static void partGroupStart(XmlWriter& xml, int number, BracketType bracket)
40994099
xml.endObject();
41004100
}
41014101

4102-
//---------------------------------------------------------
4103-
// findUnit
4104-
//---------------------------------------------------------
4105-
4106-
static bool findUnit(DurationType val, QString& unit)
4107-
{
4108-
unit = "";
4109-
switch (val) {
4110-
case DurationType::V_HALF: unit = "half";
4111-
break;
4112-
case DurationType::V_QUARTER: unit = "quarter";
4113-
break;
4114-
case DurationType::V_EIGHTH: unit = "eighth";
4115-
break;
4116-
default: LOGD("findUnit: unknown DurationType %d", int(val));
4117-
}
4118-
return true;
4119-
}
4120-
41214102
//---------------------------------------------------------
41224103
// findMetronome
41234104
//---------------------------------------------------------
@@ -4244,9 +4225,7 @@ static bool findMetronome(const std::list<TextFragment>& list,
42444225
static void beatUnit(XmlWriter& xml, const TDuration dur)
42454226
{
42464227
int dots = dur.dots();
4247-
QString unit;
4248-
findUnit(dur.type(), unit);
4249-
xml.tag("beat-unit", unit);
4228+
xml.tag("beat-unit", TConv::toXml(dur.type()));
42504229
while (dots > 0) {
42514230
xml.tagE("beat-unit-dot");
42524231
--dots;
Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
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-number>MuseScore testfile</work-number>
6+
<work-title>Tempo 5</work-title>
7+
</work>
8+
<identification>
9+
<creator type="composer">Leon Vinken</creator>
10+
<encoding>
11+
<software>MuseScore 0.7.0</software>
12+
<encoding-date>2007-09-10</encoding-date>
13+
<supports element="accidental" type="yes"/>
14+
<supports element="beam" type="yes"/>
15+
<supports element="print" attribute="new-page" type="no"/>
16+
<supports element="print" attribute="new-system" type="no"/>
17+
<supports element="stem" type="yes"/>
18+
</encoding>
19+
</identification>
20+
<part-list>
21+
<score-part id="P1">
22+
<part-name>Piano</part-name>
23+
<part-abbreviation>Pno.</part-abbreviation>
24+
<score-instrument id="P1-I1">
25+
<instrument-name>Piano</instrument-name>
26+
</score-instrument>
27+
<midi-device id="P1-I1" port="1"></midi-device>
28+
<midi-instrument id="P1-I1">
29+
<midi-channel>1</midi-channel>
30+
<midi-program>1</midi-program>
31+
<volume>78.7402</volume>
32+
<pan>0</pan>
33+
</midi-instrument>
34+
</score-part>
35+
</part-list>
36+
<part id="P1">
37+
<measure number="1">
38+
<attributes>
39+
<divisions>1</divisions>
40+
<key>
41+
<fifths>0</fifths>
42+
</key>
43+
<time>
44+
<beats>4</beats>
45+
<beat-type>4</beat-type>
46+
</time>
47+
<clef>
48+
<sign>G</sign>
49+
<line>2</line>
50+
</clef>
51+
</attributes>
52+
<direction placement="above">
53+
<direction-type>
54+
<metronome parentheses="no">
55+
<beat-unit>breve</beat-unit>
56+
<per-minute>16</per-minute>
57+
</metronome>
58+
</direction-type>
59+
<sound tempo="128"/>
60+
</direction>
61+
<note>
62+
<pitch>
63+
<step>G</step>
64+
<octave>4</octave>
65+
</pitch>
66+
<duration>4</duration>
67+
<voice>1</voice>
68+
<type>whole</type>
69+
</note>
70+
</measure>
71+
<measure number="2">
72+
<direction placement="above">
73+
<direction-type>
74+
<metronome parentheses="no">
75+
<beat-unit>whole</beat-unit>
76+
<per-minute>32</per-minute>
77+
</metronome>
78+
</direction-type>
79+
<sound tempo="128"/>
80+
</direction>
81+
<note>
82+
<pitch>
83+
<step>G</step>
84+
<octave>4</octave>
85+
</pitch>
86+
<duration>4</duration>
87+
<voice>1</voice>
88+
<type>whole</type>
89+
</note>
90+
</measure>
91+
<measure number="3">
92+
<direction placement="above">
93+
<direction-type>
94+
<metronome parentheses="no">
95+
<beat-unit>half</beat-unit>
96+
<per-minute>64</per-minute>
97+
</metronome>
98+
</direction-type>
99+
<sound tempo="128"/>
100+
</direction>
101+
<note>
102+
<pitch>
103+
<step>G</step>
104+
<octave>4</octave>
105+
</pitch>
106+
<duration>4</duration>
107+
<voice>1</voice>
108+
<type>whole</type>
109+
</note>
110+
</measure>
111+
<measure number="4">
112+
<direction placement="above">
113+
<direction-type>
114+
<metronome parentheses="no">
115+
<beat-unit>quarter</beat-unit>
116+
<per-minute>128</per-minute>
117+
</metronome>
118+
</direction-type>
119+
<sound tempo="128"/>
120+
</direction>
121+
<note>
122+
<pitch>
123+
<step>G</step>
124+
<octave>4</octave>
125+
</pitch>
126+
<duration>4</duration>
127+
<voice>1</voice>
128+
<type>whole</type>
129+
</note>
130+
</measure>
131+
<measure number="5">
132+
<direction placement="above">
133+
<direction-type>
134+
<metronome parentheses="no">
135+
<beat-unit>eighth</beat-unit>
136+
<per-minute>256</per-minute>
137+
</metronome>
138+
</direction-type>
139+
<sound tempo="128"/>
140+
</direction>
141+
<note>
142+
<pitch>
143+
<step>G</step>
144+
<octave>4</octave>
145+
</pitch>
146+
<duration>4</duration>
147+
<voice>1</voice>
148+
<type>whole</type>
149+
</note>
150+
</measure>
151+
<measure number="6">
152+
<direction placement="above">
153+
<direction-type>
154+
<metronome parentheses="no">
155+
<beat-unit>16th</beat-unit>
156+
<per-minute>512</per-minute>
157+
</metronome>
158+
</direction-type>
159+
<sound tempo="128"/>
160+
</direction>
161+
<note>
162+
<pitch>
163+
<step>G</step>
164+
<octave>4</octave>
165+
</pitch>
166+
<duration>4</duration>
167+
<voice>1</voice>
168+
<type>whole</type>
169+
</note>
170+
</measure>
171+
<measure number="7">
172+
<direction placement="above">
173+
<direction-type>
174+
<metronome parentheses="no">
175+
<beat-unit>32nd</beat-unit>
176+
<per-minute>1024</per-minute>
177+
</metronome>
178+
</direction-type>
179+
<sound tempo="128"/>
180+
</direction>
181+
<note>
182+
<pitch>
183+
<step>G</step>
184+
<octave>4</octave>
185+
</pitch>
186+
<duration>4</duration>
187+
<voice>1</voice>
188+
<type>whole</type>
189+
</note>
190+
</measure>
191+
<measure number="8">
192+
<direction placement="above">
193+
<direction-type>
194+
<metronome parentheses="no">
195+
<beat-unit>64th</beat-unit>
196+
<per-minute>2048</per-minute>
197+
</metronome>
198+
</direction-type>
199+
<sound tempo="128"/>
200+
</direction>
201+
<note>
202+
<pitch>
203+
<step>G</step>
204+
<octave>4</octave>
205+
</pitch>
206+
<duration>4</duration>
207+
<voice>1</voice>
208+
<type>whole</type>
209+
</note>
210+
</measure>
211+
<measure number="9">
212+
<direction placement="above">
213+
<direction-type>
214+
<metronome parentheses="no">
215+
<beat-unit>128th</beat-unit>
216+
<per-minute>4096</per-minute>
217+
</metronome>
218+
</direction-type>
219+
<sound tempo="128"/>
220+
</direction>
221+
<note>
222+
<pitch>
223+
<step>G</step>
224+
<octave>4</octave>
225+
</pitch>
226+
<duration>4</duration>
227+
<voice>1</voice>
228+
<type>whole</type>
229+
</note>
230+
</measure>
231+
<measure number="10">
232+
<direction placement="above">
233+
<direction-type>
234+
<metronome parentheses="no">
235+
<beat-unit>256th</beat-unit>
236+
<per-minute>8192</per-minute>
237+
</metronome>
238+
</direction-type>
239+
<sound tempo="128"/>
240+
</direction>
241+
<note>
242+
<pitch>
243+
<step>G</step>
244+
<octave>4</octave>
245+
</pitch>
246+
<duration>4</duration>
247+
<voice>1</voice>
248+
<type>whole</type>
249+
</note>
250+
</measure>
251+
<measure number="11">
252+
<direction placement="above">
253+
<direction-type>
254+
<metronome parentheses="no">
255+
<beat-unit>512th</beat-unit>
256+
<per-minute>16384</per-minute>
257+
</metronome>
258+
</direction-type>
259+
<sound tempo="128"/>
260+
</direction>
261+
<note>
262+
<pitch>
263+
<step>G</step>
264+
<octave>4</octave>
265+
</pitch>
266+
<duration>4</duration>
267+
<voice>1</voice>
268+
<type>whole</type>
269+
</note>
270+
</measure>
271+
<measure number="12">
272+
<direction placement="above">
273+
<direction-type>
274+
<metronome parentheses="no">
275+
<beat-unit>1024th</beat-unit>
276+
<per-minute>32768</per-minute>
277+
</metronome>
278+
</direction-type>
279+
<sound tempo="128"/>
280+
</direction>
281+
<note>
282+
<pitch>
283+
<step>G</step>
284+
<octave>4</octave>
285+
</pitch>
286+
<duration>4</duration>
287+
<voice>1</voice>
288+
<type>whole</type>
289+
</note>
290+
<barline location="right">
291+
<bar-style>light-heavy</bar-style>
292+
</barline>
293+
</measure>
294+
</part>
295+
</score-partwise>

src/importexport/musicxml/tests/tst_mxml_io.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ private slots:
235235
void tempo2() { mxmlIoTestRef("testTempo2"); }
236236
void tempo3() { mxmlIoTestRef("testTempo3"); }
237237
void tempo4() { mxmlIoTestRef("testTempo4"); }
238+
void tempo5() { mxmlIoTest("testTempo5"); }
238239
// void tempoOverlap() { mxmlIoTestRef("testTempoOverlap"); } fails
239240
void tempoPrecision() { mxmlMscxExportTestRef("testTempoPrecision"); }
240241
void textLines() { mxmlMscxExportTestRef("testTextLines"); }

0 commit comments

Comments
 (0)