lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

midi2ly: makeshift patch


From: Alexander Hanysz
Subject: midi2ly: makeshift patch
Date: Sun, 01 Apr 2007 16:14:31 +0930
User-agent: Mozilla Thunderbird 1.0.2-6 (X11/20050513)

It's already been mentioned that midi2ly is broken, so I thought I'd have a go at fixing it. It's my first encounter with python, so it's been an amusing experience for me, and it's still a long way off working perfectly, but it's better than nothing.

Below is a patch for what on my system is the file /usr/local/lilypond/usr/bin/midi2ly (I'm using version 2.10.20).

Fixed (?): the --key command line argument is recognised; key signatures and time signatures now appear correctly; rests are visible.

Not tested: changes of key or time within a piece.

To do: correct notation for syncopated notes and for rests that span more than one bar; the --output argument doesn't seem to work.

Unfortunately I won't have time to continue working on this. (I'm up against a deadline, so I have to go back to using Finale to finish my arrangement :-( ) But someone who actually knows what they're doing shouldn't find it too hard to fix this up. I hope that later in the year I'll be able to switch over to lilypond for all my typesetting needs.

Alexander Hanysz

---cut here---

--- /usr/local/lilypond/usr/bin/midi2ly 2007-02-25 10:33:03.000000000 +1030
+++ /home/alex/bin/midi2ly.py   2007-04-01 14:39:04.000000000 +0930
@@ -667,10 +667,12 @@


 def dump_channel (thread, skip):
-    global reference_note, time
+    global reference_note
+    #global time: moved to convert_midi (in_file, out_file)
+
+    #global_options.key = Key (0, 0, 0) # not needed?
+

-    global_options.key = Key (0, 0, 0)
-    time = Time (4, 4)
     # urg LilyPond doesn't start at c4, but
     # remembers from previous tracks!
     # reference_note = Note (clocks_per_4, 4*12, 0)
@@ -745,7 +747,7 @@
         item = thread_first_item (channels[i])

         if item and item.__class__ == Note:
-            skip = 's'
+            skip = 'r' # changed from skip = 's' -- want printed rests
             s = s + '%s = ' % (track + channel)
             if not global_options.absolute_pitches:
                 s = s + '\\relative c '
@@ -764,6 +766,9 @@
     if clef.type != 2:
         s = s + clef.dump () + '\n'

+    s = s + time.dump ()  # added
+    s = s + (global_options.key).dump () # added
+
     for i in range (len (channels)):
         channel = channel_name (i)
         item = thread_first_item (channels[i])
@@ -813,11 +818,13 @@


 def convert_midi (in_file, out_file):
-    global clocks_per_1, clocks_per_4, key
+    global clocks_per_1, clocks_per_4, key, time
     global start_quant_clocks
     global  duration_quant_clocks
     global allowed_tuplet_clocks

+    time = Time (4, 4) # moved here from dump_channel
+
     str = open (in_file).read ()
     midi_dump = midi.parse (str)

@@ -836,7 +843,7 @@

     tracks = []
     for t in midi_dump[1]:
-        global_options.key = Key (0, 0, 0)
+        # global_options.key = Key (0, 0, 0) # not needed?
         tracks.append (split_track (t))

tag = '%% Lily was here -- automatically converted by %s from %s' % ( program_name, in_file)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]