3 # (urg! wat een pokkeformaat (pokkenformaat?))
11 ls = open (fn).readlines ()
13 return re.sub ('[ \t]*%.*$\n', '', l)
16 return re.sub ('[ \n\t]+', ' ', l)
19 return re.sub ('^ ', '', re.sub (' $', '', l))
21 ls = map (stripcomment, ls)
22 ls = map (stripwhite, ls)
23 ls = map (stripeols, ls)
26 ls = filter (lambda x: x <> '', ls)
32 opening = map (string.atoi, re.split ('[\t ]+', opening))
34 (no_staffs, no_instruments, timesig_num,timesig_den, ptimesig_num,
35 ptimesig_den, pickup_beats,keysig_number) = tuple (opening)
42 # opening = map (string.atoi, re.split ('[\t ]+', opening))
43 # (no_pages,no_systems, musicsize, fracindent) = tuple (opening)
46 while len (instruments) < no_instruments:
47 instruments.append (ls[0])
58 staffs = map (lambda x: Staff (), range(0, no_staffs))
71 actab = {-2: 'eses', -1: 'es', 0 : '', 1: 'is', 2:'isis'}
73 def pitch_to_lily_string (tup):
76 nm = chr((n + 2) % 7 + ord ('a'))
88 self.basic_duration = 0
93 for p in self.pitches:
96 str = str + pitch_to_lily_string (p)
98 if len (self.pitches) > 1:
100 elif len (self.pitches) == 0:
105 if self.basic_duration == 0.5:
108 sd = '%d' % self.basic_duration
110 str = str + sd + '.' * self.dots
114 input_left = string.join (ls, ' ')
117 input_left = re.sub ('[ \t\n]+', ' ', input_left)
135 self.forced_duration = None
138 def parse_note (self, str):
143 name = (ord (str[0]) - ord('a') + 5) % 7
152 while str[0] in 'dsfmnul0123456789.,':
156 alteration = alteration -1
162 alteration = alteration +1
165 elif c in DIGITS and durdigit == None:
166 durdigit = string.atoi (c)
168 oct = string.atoi (c) - 4
177 ch.basic_duration = basicdur_table[durdigit]
178 self.last_basic_duration = ch.basic_duration
180 ch.basic_duration = self.last_basic_duration
184 self.last_octave =oct
186 oct = self.last_octave
189 ch.pitches.append ((oct, name, alteration))
195 self.forced_duration = ch.basic_duration / forced_duration
198 self.chords.append (ch)
199 while str[0] in SPACE:
206 while input_left[0] in 'abcdefgr':
207 input_left = parser.parse_note (input_left)
210 sys.stderr.write ("\nHuh? Unknown directive %s" %input_left[0:1])
211 input_left = input_left[1:]
215 for c in parser.chords: