]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/etf2ly.py
* Another grand 2003 update.
[lilypond.git] / scripts / etf2ly.py
index 1c9487df19505691e25596816b0ab2a2b09b04b7..cf09f3dfa3fba714063de1a1742427a9033d3947 100644 (file)
@@ -1,7 +1,7 @@
 #!@PYTHON@
 
 # info mostly taken from looking at files. See also
-# http://www.cs.uu.nl/~hanwen/lily-devel/etf.html
+# http://lilypond.org/wiki/?EnigmaTransportFormat
 
 # This supports
 #
@@ -24,7 +24,7 @@
 #  * dynamics
 #  * empty measures (eg. twopt03.etf from freenote)
 #
-# 
+
 
 program_name = 'etf2ly'
 version = '@TOPLEVEL_VERSION@'
@@ -174,16 +174,7 @@ def lily_notename (tuple2):
        (n, a) = tuple2
        nn = chr ((n+ 2)%7 + ord ('a'))
 
-       if a == -1:
-               nn = nn + 'es'
-       elif a == -2:
-               nn = nn + 'eses'
-       elif a == 1:
-               nn = nn + 'is'
-       elif a == 2:
-               nn = nn + 'isis'
-
-       return nn
+       return nn + {-2:'eses', -1:'es', 0:'', 1:'is', 2:'isis'}[a]
 
 
 class Tuplet:
@@ -242,8 +233,9 @@ class Slur:
                        if not cs or not ce:
                                raise IndexError
                        
-                       cs.note_suffix = '(' + cs.note_suffix 
-                       ce.note_prefix = ce.note_prefix + ')'
+                       cs.note_suffix = '-(' + cs.note_suffix 
+                       ce.note_suffix = ce.note_suffix + '-)'
+                       
                except IndexError:
                        sys.stderr.write ("""\nHuh? Slur no %d between (%d,%d), with %d notes""" % (self.number,  startnote, endnote, len (chords)))
                                         
@@ -265,7 +257,8 @@ class Global_measure:
        def set_timesig (self, finale):
                (beats, fdur) = finale
                (log, dots) = EDU_to_duration (fdur)
-               assert dots == 0
+               if dots <> 0:
+                       sys.stderr.write ("\nHuh? Beat duration has a dot? (EDU Duration = %d)" % fdur) 
                self.timesig = (beats, log)
 
        def length (self):
@@ -708,15 +701,18 @@ class Chord:
                        if rest:
                                nn = rest
                                
-                       s = s + '%s%d%s' % (nn, self.duration[0], '.'* self.duration[1])
+                       s = s + nn 
 
                if not self.pitches:
-                       s  = 'r%d%s' % (self.duration[0] , '.'* self.duration[1])
-               s = self.note_prefix + s + self.note_suffix
+                       s  = 'r'
                if len (self.pitches) > 1:
-                       s = '<%s>' % s
+                       s = '<< %s >>' % s
+
+               s = s + '%d%s' % (self.duration[0], '.'* self.duration[1])
+               s = self.note_prefix + s + self.note_suffix
                
                s = self.chord_prefix + s + self.chord_suffix
+
                return s
 
 
@@ -729,6 +725,10 @@ Add None to LIST until it contains entry number NO.
        return list
 
 def read_finale_value (str):
+       """
+Pry off one value from STR. The value may be $hex, decimal, or "string".
+Return: (value, rest-of-STR)
+       """
        while str and str[0] in ' \t\n':
                str = str[1:]
 
@@ -997,8 +997,11 @@ class Etf_file:
                                
                                frame_obj_list = [None]
                                for frno in m.frames:
-                                       fr = self.frames[frno]
-                                       frame_obj_list.append (fr)
+                                       try:
+                                               fr = self.frames[frno]
+                                               frame_obj_list.append (fr)
+                                       except IndexError:
+                                               sys.stderr.write ("\nNon-existent frame %d"  % frno)
 
                                m.frames = frame_obj_list
                                for fr in frame_obj_list[1:]:
@@ -1102,7 +1105,7 @@ Enigma Transport Format is a format used by Coda Music Technology's
 Finale product. This program will convert a subset of ETF to a
 ready-to-use lilypond file.
 
-Report bugs to bug-gnu-music@gnu.org
+Report bugs to bug-lilypond@gnu.org
 
 Written by  Han-Wen Nienhuys <hanwen@cs.uu.nl>
 """)
@@ -1114,7 +1117,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 by Han-Wen Nienhuys <hanwen@cs.uu.nl>
+Copyright (c)  2000--2003 by Han-Wen Nienhuys <hanwen@cs.uu.nl>
 """ % version)