]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/musicxml/generate_keys.py
Merge branch 'master' of ssh+git://hanwen@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / input / regression / musicxml / generate_keys.py
1 #!/usr/bin/env python
2
3 notes = "CDEFGAB"
4 alterations = [-1, 0, 1]
5
6 def print_measure (nr, fifth, mode, atts = "", final = ""):
7     print """    <measure number="%s">
8       <attributes>
9 %s        <key>
10           <fifths>%s</fifths>
11           <mode>%s</mode>
12         </key>
13       </attributes>
14       <note>
15         <pitch>
16           <step>C</step>
17           <octave>4</octave>
18         </pitch>
19         <duration>2</duration>
20         <voice>1</voice>
21         <type>half</type>
22       </note>
23 %s    </measure>""" % (nr, atts,  fifth, mode, final)
24
25 first_atts = """        <divisions>1</divisions>
26         <time symbol="common">
27           <beats>2</beats>
28           <beat-type>4</beat-type>
29         </time>
30         <clef>
31           <sign>G</sign>
32           <line>2</line>
33         </clef>
34 """
35
36 final_barline = """      <barline location="right">
37         <bar-style>light-heavy</bar-style>
38       </barline>
39 """
40
41 print """<?xml version="1.0" encoding="UTF-8"?>
42 <!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.0 Partwise//EN"
43                                 "http://www.musicxml.org/dtds/partwise.dtd">
44 <score-partwise>
45   <movement-title>Different Key signatures</movement-title>
46   <part-list>
47     <score-part id="P1">
48       <part-name>MusicXML Part</part-name>
49     </score-part>
50   </part-list>
51   <!--=========================================================-->
52   <part id="P1">
53 """
54
55 max_range = 11
56 measure = 0
57 for fifth in range(-max_range, max_range+1):
58     measure += 1
59     if fifth == -max_range:
60         print_measure (measure, fifth, "major", first_atts)
61     else:
62         print_measure (measure, fifth, "major")
63     measure += 1
64     if fifth == max_range:
65         print_measure (measure, fifth, "minor", "", final_barline)
66     else:
67         print_measure (measure, fifth, "minor")
68     
69
70 print """  </part>
71 </score-partwise>
72 """