]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/abc2ly.py
Merge branch 'master' of git://git.sv.gnu.org/lilypond
[lilypond.git] / scripts / abc2ly.py
index 9b15bfceb0e2d2d1971149ec04f14100300d11db..9c697367b4fc020b285ad137cae64deeff5ab213 100644 (file)
@@ -33,6 +33,7 @@
 # %%LY now supported.
 # \breve and \longa supported.
 # M:none doesn't crash lily.
+# lilypond '--' supported.
 
 # Enhancements (Guy Gascoigne-Piggford)
 #
@@ -254,13 +255,13 @@ def try_parse_q(a):
     if string.count(a, '/') == 1:
         array=string.split(a,'/')
         numerator=array[0]
-        if numerator != 1:
+        if int(numerator) != 1:
             sys.stderr.write("abc2ly: Warning, unable to translate a Q specification with a numerator of %s: %s\n" % (numerator, a))
         array2=string.split(array[1],'=')
         denominator=array2[0]
         perminute=array2[1]
         duration=str(string.atoi(denominator)/string.atoi(numerator))
-        midi_specs=string.join(["\\tempo", duration, "=", perminute])
+        midi_specs=string.join(["    \n\t\t\context {\n\t\t \Score tempoWholesPerMinute = #(ly:make-moment ", perminute, " ", duration, ")\n\t\t }\n"])
     else:
         sys.stderr.write("abc2ly: Warning, unable to parse Q specification: %s\n" % a)
     
@@ -327,7 +328,7 @@ def gulp_file(f):
         n = i.tell ()
         i.seek (0,0)
     except:
-        sys.stderr.write ("can't open file: `%s'\n" % f)
+        sys.stderr.write ("cannot open file: `%s'\n" % f)
         return ''
     s = i.read (n)
     if len (s) <= 0:
@@ -616,7 +617,7 @@ def fix_lyric(str):
 
 def slyrics_append(a):
     a = re.sub ( '_', ' _ ', a)        # _ to ' _ '
-    a = re.sub ( '-', '- ', a)        # split words with -
+    a = re.sub ( '([^-])-([^-])', '\\1- \\2', a)        # split words with "-" unless was originally "--" 
     a = re.sub ( '\\\\- ', '-', a)         # unless \-
     a = re.sub ( '~', '_', a)        # ~ to space('_')
     a = re.sub ( '\*', '_ ', a)        # * to to space
@@ -889,6 +890,8 @@ artic_tbl = {
     '~' : '^"~" ',
     'J' : '',                # ignore slide
     'R' : '',                # ignore roll
+    'S' : '^\\segno',
+    'O' : '^\\coda',
     'v' : '^\\downbow'
 }
     
@@ -1335,7 +1338,7 @@ def identify():
     sys.stderr.write ("%s from LilyPond %s\n" % (program_name, version))
 
 authors = """
-Written by Han-Wen Nienhuys <hanwen@cs.uu.nl>, Laura Conrad
+Written by Han-Wen Nienhuys <hanwen@xs4all.nl>, Laura Conrad
 <lconrad@laymusic.org>, Roy Rankin <Roy.Rankin@@alcatel.com.au>.
 """
 
@@ -1343,28 +1346,29 @@ def print_version ():
     print r"""abc2ly (GNU lilypond) %s""" % version
 
 def get_option_parser ():
-    p = ly.get_option_parser (usage='abc2ly [OPTIONS] FILE',
+    p = ly.get_option_parser (usage=_ ("%s [OPTION]... FILE") % 'abc2ly',
                  version="abc2ly (LilyPond) @TOPLEVEL_VERSION@",
-                 description=_('''This program converts ABC music files (see
-http://www.gre.ac.uk/~c.walshaw/abc2mtex/abc.txt) to LilyPond input.'''))
-
-    p.add_option ('-o', '--output', metavar='FILE',help=_("set output filename to FILE"),
-           action='store')
-    p.add_option ('-s', '--strict', help=_("be strict about succes"),
-           action='store_true')
-    p.add_option ('-b', '--beams', help=_("preserve ABC's notion of beams"))
-    p.add_option_group  ('bugs',
-              description='''Report bugs via http://post.gmane.org/post.php'''
-              '''?group=gmane.comp.gnu.lilypond.bugs\n''')
-    
+                 description=_ ('''abc2ly converts ABC music files (see
+%s) to LilyPond input.''') % 'http://www.gre.ac.uk/~c.walshaw/abc2mtex/abc.txt')
+
+    p.add_option ('-o', '--output', metavar='FILE',
+                  help=_ ("write output to FILE"),
+                  action='store')
+    p.add_option ('-s', '--strict', help=_ ("be strict about succes"),
+                  action='store_true')
+    p.add_option ('-b', '--beams', help=_ ("preserve ABC's notion of beams"))
+    p.add_option_group ('bugs',
+                        description=(_ ('Report bugs via')
+                                     + ''' http://post.gmane.org/post.php'''
+                                     '''?group=gmane.comp.gnu.lilypond.bugs\n'''))
     return p
 
 
-option_parser = get_option_parser()
-(global_options, files) = option_parser.parse_args()
+option_parser = get_option_parser ()
+(global_options, files) = option_parser.parse_args ()
 
 
-identify()
+identify ()
 
 header['tagline'] = 'Lily was here %s -- automatically converted from ABC' % version
 for f in files: