Skip to content

Commit b92da28

Browse files
committed
Add test for repeats with alternatives
1 parent 5f86e7b commit b92da28

File tree

3 files changed

+326
-0
lines changed

3 files changed

+326
-0
lines changed

tests/test_xml.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def test_tuplet():
3434
def test_repeat():
3535
compare_output('repeat')
3636

37+
def test_repeat_with_alternative():
38+
compare_output('repeat_with_alternative')
39+
3740
def ly_to_xml(filename):
3841
"""Read Lilypond file and return XML string."""
3942
writer = ly.musicxml.writer()
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
\version "2.19.55"
2+
3+
\header {
4+
title = "repeat with alternative"
5+
}
6+
7+
\score {
8+
\relative c'{
9+
% Simple repeat with a simple alternative
10+
c1 |
11+
\repeat volta 2{ c1| }
12+
\alternative {
13+
{ d1 | }
14+
{ d1 | e1 |}
15+
}
16+
17+
% Simple repeat with more repeats than alternatives
18+
c1 |
19+
\repeat volta 3{ c1| }
20+
\alternative {
21+
{ d1 | }
22+
{ d1 | e1 |}
23+
}
24+
25+
% Simple repeat with many endings
26+
c1 |
27+
\repeat volta 5{ c1| }
28+
\alternative {
29+
{ d1 | e1 |}
30+
{ d1 | f1 |}
31+
{ d1 |}
32+
}
33+
}
34+
\layout {}
35+
}
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0 Partwise//EN"
3+
"http://www.musicxml.org/dtds/partwise.dtd">
4+
<score-partwise version="3.0">
5+
<movement-title>repeat with alternative</movement-title>
6+
<identification>
7+
<encoding>
8+
<software>python-ly 0.9.5</software>
9+
<encoding-date>2016-03-28</encoding-date>
10+
</encoding>
11+
</identification>
12+
<part-list>
13+
<score-part id="P1">
14+
<part-name />
15+
</score-part>
16+
</part-list>
17+
<part id="P1">
18+
<measure number="1">
19+
<attributes>
20+
<divisions>1</divisions>
21+
<time symbol="common">
22+
<beats>4</beats>
23+
<beat-type>4</beat-type>
24+
</time>
25+
<clef>
26+
<sign>G</sign>
27+
<line>2</line>
28+
</clef>
29+
</attributes>
30+
<note>
31+
<pitch>
32+
<step>C</step>
33+
<octave>4</octave>
34+
</pitch>
35+
<duration>4</duration>
36+
<voice>1</voice>
37+
<type>whole</type>
38+
</note>
39+
</measure>
40+
<measure number="2">
41+
<barline location="left">
42+
<bar-style>heavy-light</bar-style>
43+
<repeat direction="forward" />
44+
</barline>
45+
<note>
46+
<pitch>
47+
<step>C</step>
48+
<octave>4</octave>
49+
</pitch>
50+
<duration>4</duration>
51+
<voice>1</voice>
52+
<type>whole</type>
53+
</note>
54+
</measure>
55+
<measure number="3">
56+
<barline location="left">
57+
<ending number="1" type="start">1.</ending>
58+
</barline>
59+
<barline location="right">
60+
<bar-style>light-heavy</bar-style>
61+
<repeat direction="backward" />
62+
</barline>
63+
<barline location="right">
64+
<ending number="1" type="stop" />
65+
</barline>
66+
<note>
67+
<pitch>
68+
<step>D</step>
69+
<octave>4</octave>
70+
</pitch>
71+
<duration>4</duration>
72+
<voice>1</voice>
73+
<type>whole</type>
74+
</note>
75+
</measure>
76+
<measure number="4">
77+
<barline location="left">
78+
<ending number="2" type="start">2.</ending>
79+
</barline>
80+
<note>
81+
<pitch>
82+
<step>D</step>
83+
<octave>4</octave>
84+
</pitch>
85+
<duration>4</duration>
86+
<voice>1</voice>
87+
<type>whole</type>
88+
</note>
89+
</measure>
90+
<measure number="5">
91+
<barline location="right">
92+
<ending number="2" type="discontinue" />
93+
</barline>
94+
<note>
95+
<pitch>
96+
<step>E</step>
97+
<octave>4</octave>
98+
</pitch>
99+
<duration>4</duration>
100+
<voice>1</voice>
101+
<type>whole</type>
102+
</note>
103+
</measure>
104+
<measure number="6">
105+
<note>
106+
<pitch>
107+
<step>C</step>
108+
<octave>4</octave>
109+
</pitch>
110+
<duration>4</duration>
111+
<voice>1</voice>
112+
<type>whole</type>
113+
</note>
114+
</measure>
115+
<measure number="7">
116+
<barline location="left">
117+
<bar-style>heavy-light</bar-style>
118+
<repeat direction="forward" />
119+
</barline>
120+
<note>
121+
<pitch>
122+
<step>C</step>
123+
<octave>4</octave>
124+
</pitch>
125+
<duration>4</duration>
126+
<voice>1</voice>
127+
<type>whole</type>
128+
</note>
129+
</measure>
130+
<measure number="8">
131+
<barline location="left">
132+
<ending number="1,2" type="start">1., 2.</ending>
133+
</barline>
134+
<barline location="right">
135+
<bar-style>light-heavy</bar-style>
136+
<repeat direction="backward" times="3" />
137+
</barline>
138+
<barline location="right">
139+
<ending number="1,2" type="stop" />
140+
</barline>
141+
<note>
142+
<pitch>
143+
<step>D</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="9">
152+
<barline location="left">
153+
<ending number="3" type="start">3.</ending>
154+
</barline>
155+
<note>
156+
<pitch>
157+
<step>D</step>
158+
<octave>4</octave>
159+
</pitch>
160+
<duration>4</duration>
161+
<voice>1</voice>
162+
<type>whole</type>
163+
</note>
164+
</measure>
165+
<measure number="10">
166+
<barline location="right">
167+
<ending number="3" type="discontinue" />
168+
</barline>
169+
<note>
170+
<pitch>
171+
<step>E</step>
172+
<octave>4</octave>
173+
</pitch>
174+
<duration>4</duration>
175+
<voice>1</voice>
176+
<type>whole</type>
177+
</note>
178+
</measure>
179+
<measure number="11">
180+
<note>
181+
<pitch>
182+
<step>C</step>
183+
<octave>4</octave>
184+
</pitch>
185+
<duration>4</duration>
186+
<voice>1</voice>
187+
<type>whole</type>
188+
</note>
189+
</measure>
190+
<measure number="12">
191+
<barline location="left">
192+
<bar-style>heavy-light</bar-style>
193+
<repeat direction="forward" />
194+
</barline>
195+
<note>
196+
<pitch>
197+
<step>C</step>
198+
<octave>4</octave>
199+
</pitch>
200+
<duration>4</duration>
201+
<voice>1</voice>
202+
<type>whole</type>
203+
</note>
204+
</measure>
205+
<measure number="13">
206+
<barline location="left">
207+
<ending number="1,2,3" type="start">1., 2., 3.</ending>
208+
</barline>
209+
<note>
210+
<pitch>
211+
<step>D</step>
212+
<octave>4</octave>
213+
</pitch>
214+
<duration>4</duration>
215+
<voice>1</voice>
216+
<type>whole</type>
217+
</note>
218+
</measure>
219+
<measure number="14">
220+
<barline location="right">
221+
<bar-style>light-heavy</bar-style>
222+
<repeat direction="backward" times="4" />
223+
</barline>
224+
<barline location="right">
225+
<ending number="1,2,3" type="stop" />
226+
</barline>
227+
<note>
228+
<pitch>
229+
<step>E</step>
230+
<octave>4</octave>
231+
</pitch>
232+
<duration>4</duration>
233+
<voice>1</voice>
234+
<type>whole</type>
235+
</note>
236+
</measure>
237+
<measure number="15">
238+
<barline location="left">
239+
<ending number="4" type="start">4.</ending>
240+
</barline>
241+
<note>
242+
<pitch>
243+
<step>D</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="16">
252+
<barline location="right">
253+
<bar-style>light-heavy</bar-style>
254+
<repeat direction="backward" />
255+
</barline>
256+
<barline location="right">
257+
<ending number="4" type="stop" />
258+
</barline>
259+
<note>
260+
<pitch>
261+
<step>F</step>
262+
<octave>4</octave>
263+
</pitch>
264+
<duration>4</duration>
265+
<voice>1</voice>
266+
<type>whole</type>
267+
</note>
268+
</measure>
269+
<measure number="17">
270+
<barline location="left">
271+
<ending number="5" type="start">5.</ending>
272+
</barline>
273+
<barline location="right">
274+
<ending number="5" type="discontinue" />
275+
</barline>
276+
<note>
277+
<pitch>
278+
<step>D</step>
279+
<octave>4</octave>
280+
</pitch>
281+
<duration>4</duration>
282+
<voice>1</voice>
283+
<type>whole</type>
284+
</note>
285+
</measure>
286+
<measure number="18" />
287+
</part>
288+
</score-partwise>

0 commit comments

Comments
 (0)