]> git.donarmstrong.com Git - lilypond.git/blob - buildscripts/generate_timesignatures.py
The IR guide
[lilypond.git] / buildscripts / generate_timesignatures.py
1 #!/usr/bin/env python
2
3 notes = "CDEFGAB"
4 alterations = [-1, 0, 1]
5
6 def print_measure (nr, beats, type, params = "", attr = "", barline = ""):
7     print """    <measure number="%s">
8       <attributes>
9 %s        <time %s>
10           <beats>%s</beats>
11           <beat-type>%s</beat-type>
12         </time>
13       </attributes>
14       <note>
15         <pitch>
16           <step>C</step>
17           <octave>5</octave>
18         </pitch>
19         <duration>1</duration>
20         <voice>1</voice>
21         <type>quarter</type>
22       </note>
23 %s    </measure>""" % (nr, attr, params, beats, type, barline)
24
25 first_atts = """        <divisions>1</divisions>
26         <key>
27           <fifths>0</fifths>
28           <mode>major</mode>
29         </key>
30         <time symbol="common">
31           <beats>2</beats>
32           <beat-type>4</beat-type>
33         </time>
34         <clef>
35           <sign>G</sign>
36           <line>2</line>
37         </clef>
38 """
39
40 final_barline = """      <barline location="right">
41         <bar-style>light-heavy</bar-style>
42       </barline>
43 """
44
45 print """<?xml version="1.0" encoding="UTF-8"?>
46 <!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.0 Partwise//EN"
47                                 "http://www.musicxml.org/dtds/partwise.dtd">
48 <score-partwise>
49   <movement-title>Different time signatures</movement-title>
50   <part-list>
51     <score-part id="P1">
52       <part-name>MusicXML Part</part-name>
53     </score-part>
54   </part-list>
55   <!--=========================================================-->
56   <part id="P1">
57 """
58
59 measure = 1
60
61 print_measure (measure, 2, 2, " symbol=\"common\"", first_atts)
62 measure += 1
63
64 print_measure (measure, 4, 4, " symbol=\"common\"")
65 measure += 1
66
67 print_measure (measure, 2, 2)
68 measure += 1
69
70 print_measure (measure, 3, 2)
71 measure += 1
72
73 print_measure (measure, 2, 4)
74 measure += 1
75
76 print_measure (measure, 3, 4)
77 measure += 1
78
79 print_measure (measure, 4, 4)
80 measure += 1
81
82 print_measure (measure, 5, 4)
83 measure += 1
84
85 print_measure (measure, 3, 8)
86 measure += 1
87
88 print_measure (measure, 6, 8)
89 measure += 1
90
91 print_measure (measure, 12, 8, "", "", final_barline)
92 measure += 1
93
94 print """  </part>
95 </score-partwise>
96 """