]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/pmx2ly.py
* Another grand 2003 update.
[lilypond.git] / scripts / pmx2ly.py
index 412906db09cefafd35d2115a870553b01b315569..7328ed1505f46b13ec87b87534db7ddc5200dc3f 100644 (file)
@@ -135,11 +135,12 @@ class Slur:
                e= self.end_chord
 
                if e and s:
-                       s.note_suffix = s.note_suffix + '('
-                       e.note_prefix = ')' + e.note_prefix
+                       s.note_suffix = s.note_suffix + '-('
+                       e.note_prefix = e.note_suffix + '-)' 
                else:
                        sys.stderr.write ("\nOrphaned slur")
-                       
+
+
 class Voice:
        def __init__ (self):
                self.entries = []
@@ -161,6 +162,7 @@ class Voice:
                
        def last_chord (self):
                return self.chords[-1]
+       
        def add_chord (self, ch):
                self.chords.append (ch)
                self.entries.append (ch)
@@ -257,9 +259,11 @@ class Staff:
                        v.number = i
                        i = i+1
        def set_clef (self, letter):
-               clstr = clef_table[letter]
-               self.voices[0].add_nonchord (Clef (clstr))
-
+               if clef_table.has_key (letter):
+                       clstr = clef_table[letter]
+                       self.voices[0].add_nonchord (Clef (clstr))
+               else:
+                       sys.stderr.write ("Clef type `%c' unknown\n" % letter)
        
        def current_voice (self):
                return self.voices[self.voice_idx]
@@ -337,18 +341,18 @@ class Chord:
                for p in self.pitches:
                        if str:
                                str = str + ' ' 
-                       str = str + pitch_to_lily_string (p) + sd
-
-               for s in self.scripts:
-                       str = str + '-' + s
+                       str = str + pitch_to_lily_string (p) 
 
-               str = self.note_prefix +str  + self.note_suffix
-               
                if len (self.pitches) > 1:
-                       str = '<%s>' % str
+                       str = '<<%s>>' % str
                elif len (self.pitches) == 0:
-                       str = 'r' + sd
+                       str = 'r'
 
+               str = str + sd
+               for s in self.scripts:
+                       str = str + '-' + s
+
+               str = self.note_prefix + str + self.note_suffix
                str = self.chord_prefix + str + self.chord_suffix
                
                return str
@@ -599,7 +603,7 @@ Huh? expected duration, found %d Left was `%s'""" % (durdigit, str[:20]))
                        numbers = numbers + map (atonum, opening)
 
                (no_staffs, no_instruments, timesig_num, timesig_den, ptimesig_num,
-                ptimesig_den, pickup_beats,keysig_number) = tuple (numbers[0:8])
+                esig_den, pickup_beats,keysig_number) = tuple (numbers[0:8])
                (no_pages,no_systems, musicsize, fracindent) = tuple (numbers[8:])
 
                # ignore this.
@@ -764,11 +768,13 @@ Huh? Unknown directive `%s', before `%s'""" % (c, left[:20] ))
                ls = open (fn).readlines ()
                def subst(s):
                        return re.sub ('%.*$', '', s)
+               
                ls = map (subst, ls)
+               ls = filter (lambda x: x <> '\n', ls)
                ls = self.parse_header (ls)
                left = string.join (ls, ' ')
 
-               print left
+#              print left
                self.parse_body (left)
                for c in self.staffs:
                        c.calculate ()
@@ -804,7 +810,7 @@ This is free software.  It is covered by the GNU General Public License,
 and you are welcome to change it and/or distribute copies of it under
 certain conditions.  Invoke as `midi2ly --warranty' for more information.
 
-Copyright (c) 2000--2002 by Han-Wen Nienhuys <hanwen@cs.uu.nl>
+Copyright (c)  2000--2003 by Han-Wen Nienhuys <hanwen@cs.uu.nl>
 """ % version)
 def identify():
        sys.stderr.write ("%s from LilyPond %s\n" % (program_name, version))