[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
pmx2ly crashes
From: |
Han-Wen Nienhuys |
Subject: |
pmx2ly crashes |
Date: |
Mon, 3 Dec 2001 00:14:10 +0100 |
address@hidden writes:
> pmx2ly crashes on the attached file (generated by rosegarden from a
> MIDI file). pmx generates a dvi file, which has some problems, but
> basically looks like the music I expect.
Try the following patch. It now barfs with
Huh? Unknown directive `C', before `Cn K+0+1 e43 zg g82 '
I don't know enough PMX to decide how C should be supported. Maybe you
can have a look for yourself.
--- pmx2ly.py~ Thu Apr 5 00:12:30 2001
+++ pmx2ly.py Mon Dec 3 00:11:14 2001
@@ -534,44 +534,42 @@
def parse_header (self, ls):
- while ls[0][0] == '%':
- ls = ls[1:]
+ def atonum(a):
+ if re.search('\\.', a):
+ return string.atof (a)
+ else:
+ return string.atoi (a)
- opening = ls[0]
- ls = ls[1:]
-
- opening = re.sub ('^[ \t]+', '', opening)
- opening = re.sub ('[ \t]+$', '', opening)
- opening = re.split ('[\t ]+', opening)
-
- (no_staffs, no_instruments, timesig_num,timesig_den,
ptimesig_num,
- ptimesig_den, pickup_beats,keysig_number) = opening
- (no_staffs, no_instruments, timesig_num, timesig_den,
ptimesig_num, ptimesig_den, keysig_number) = tuple (map (string.atoi ,
[no_staffs, no_instruments, timesig_num, timesig_den, ptimesig_num,
ptimesig_den, keysig_number]))
- try:
- pickup_beats = string.atoi (pickup_beats)
- except ValueError:
- pickup_beats = string.atof (pickup_beats)
-
+ number_count = 12
+ numbers = []
- while ls[0][0] == '%':
+ while len (numbers) < number_count:
+ opening = ls[0]
ls = ls[1:]
-
- opening = ls[0]
- ls = ls[1:]
+
+ opening = re.sub ('[ \t\n]+', ' ', opening)
+ opening = re.sub ('^ ', '', opening)
+ opening = re.sub (' $', '', opening)
+ if opening == '':
+ continue
+ opening = string.split (opening, ' ')
+
+ numbers = numbers + map (atonum, opening)
+
+ print numbers
+
+ (no_staffs, no_instruments, timesig_num, timesig_den,
ptimesig_num,
+ ptimesig_den, pickup_beats,keysig_number) = tuple
(numbers[0:8])
+ (no_pages,no_systems, musicsize, fracindent) = tuple
(numbers[8:])
# ignore this.
# opening = map (string.atoi, re.split ('[\t ]+', opening))
- # (no_pages,no_systems, musicsize, fracindent) = tuple (opening)
-
+
instruments = []
while len (instruments) < no_instruments:
instruments.append (ls[0])
ls = ls[1:]
-
- while ls[0][0] == '%':
- ls = ls[1:]
-
l = ls[0]
ls = ls[1:]
@@ -582,9 +580,6 @@
l = l[1:]
# dump path
- while ls[0][0] == '%':
- ls = ls[1:]
-
ls = ls[1:]
# dump more ?
@@ -722,6 +717,9 @@
def parse (self,fn):
ls = open (fn).readlines ()
+ def subst(s):
+ return re.sub ('%.*$', '', s)
+ ls = map (subst, ls)
ls = self.parse_header (ls)
left = string.join (ls, ' ')
--
Han-Wen Nienhuys | address@hidden | http://www.cs.uu.nl/~hanwen/
- pmx2ly crashes, Laura Conrad, 2001/12/02
- pmx2ly crashes,
Han-Wen Nienhuys <=