]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/midi2ly.py
* scripts/musedata2ly.py (): idem
[lilypond.git] / scripts / midi2ly.py
index ea47e1583576a86262b90ee803a8d5eff974fef7..3b3f00dd9eb7a0ddd886b67acbb3036ef7ca6701 100644 (file)
@@ -4,8 +4,8 @@
 # 
 # source file of the GNU LilyPond music typesetter
 #
-# convert MIDI to LilyPond source
-#
+# (c) 1998--2002  Han-Wen Nienhuys <hanwen@cs.uu.nl>
+#                 Jan Nieuwenhuizen <janneke@gnu.org>
 
 
 '''
@@ -429,7 +429,8 @@ class Note:
 
                return (o, n, a)
                
-       def dump (self):
+       def dump (self, dump_dur = 1):
+               global reference_note
                s = chr ((self.notename + 2)  % 7 + ord ('a'))
                s = s + self.alteration_names[self.alteration + 2]
                if absolute_p:
@@ -449,11 +450,11 @@ class Note:
                elif commas < 0:
                        s = s + "," * -commas
 
-               if explicit_durations_p \
-                  or Duration.compare (self.duration, reference_note.duration):
+               if and dump_dur (explicit_durations_p \
+                  or Duration.compare (self.duration,
+                                       reference_note.duration)):
                        s = s + self.duration.dump ()
 
-               global reference_note
                reference_note = self
                
                # TODO: move space
@@ -787,12 +788,14 @@ def dump_chord (ch):
                s = s + dump (notes[0])
        elif len (notes) > 1:
                global reference_note
-               s = s + '<'
-               s = s + notes[0].dump ()
+               s = s + '<<'
+               s = s + notes[0].dump (dump_dur = 0)
                r = reference_note
                for i in notes[1:]:
-                       s = s + i.dump ()
-               s = s + '>'
+                       s = s + i.dump (dump_dur = 0 )
+               s = s + '>>'
+
+               s = s + notes[0].duration.dump()
                reference_note = r
        return s
 
@@ -1051,13 +1054,10 @@ for opt in options:
 
 
        elif o == '--absolute-pitches' or o == '-a':
-               global absolute_p
                absolute_p = 1
        elif o == '--duration-quant' or o == '-d':
-               global duration_quant
                duration_quant = string.atoi (a)
        elif o == '--explicit-durations' or o == '-e':
-               global explicit_durations_p
                explicit_durations_p = 1
        elif o == '--key' or o == '-k':
                (alterations, minor) = map (string.atoi, string.split (a + ':0', ':'))[0:2]
@@ -1067,7 +1067,6 @@ for opt in options:
                        sharps = alterations
                else:
                        flats = - alterations
-               global key
                key = Key (sharps, flats, minor)
        elif o == '--start-quant' or o == '-s':
                start_quant = string.atoi (a)