X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fetf2ly.py;h=6ed2d18a7ff5fbf4321bd27d333b4005716c9bac;hb=6dc25f04195169860be7f336031ed8baa98cdc40;hp=34a1c9e01860e2aba8d835a20512973af5d97052;hpb=7e72a1e50e94a7f9738d62599de79fe7745f600c;p=lilypond.git diff --git a/scripts/etf2ly.py b/scripts/etf2ly.py index 34a1c9e018..6ed2d18a7f 100644 --- a/scripts/etf2ly.py +++ b/scripts/etf2ly.py @@ -26,11 +26,6 @@ # -program_name = 'etf2ly' -version = '@TOPLEVEL_VERSION@' -if version == '@' + 'TOPLEVEL_VERSION' + '@': - version = '(unknown version)' # uGUHGUHGHGUGH - import __main__ import getopt import sys @@ -38,6 +33,12 @@ import re import string import os +program_name = sys.argv[0] + +version = '@TOPLEVEL_VERSION@' +if version == '@' + 'TOPLEVEL_VERSION' + '@': + version = '(unknown version)' # uGUHGUHGHGUGH + finale_clefs= ['treble', 'alto', 'tenor', 'bass', 'percussion', 'treble_8', 'bass_8', 'baritone'] def lily_clef (fin): @@ -108,9 +109,9 @@ have the correct number of accidentals # should cache this. def find_scale (keysig): cscale = map (lambda x: (x,0), range (0,7)) - print "cscale: ", cscale +# print "cscale: ", cscale ascale = map (lambda x: (x,0), range (-2,5)) - print "ascale: ", ascale +# print "ascale: ", ascale transposition = keysig.pitch if keysig.sig_type == 1: transposition = transpose(transposition, (2, -1)) @@ -118,7 +119,7 @@ def find_scale (keysig): trscale = map(lambda x, k=transposition: transpose(x, k), ascale) else: trscale = map(lambda x, k=transposition: transpose(x, k), cscale) - print "trscale: ", trscale +# print "trscale: ", trscale return trscale def EDU_to_duration (edu): @@ -136,7 +137,7 @@ def EDU_to_duration (edu): dots = 2 return (log, dots) -def rat_to_lily_duration (rat): +def rational_to_lily_skip (rat): (n,d) = rat basedur = 1 @@ -394,7 +395,7 @@ class Verse: str = str + ' ' * 4 + line + '\n' line = '' - str = """\nverse%s = \\lyrics {\n %s}\n""" % (encodeint (self.number - 1) ,str) + str = """\nverse%s = \\lyricmode {\n %s }\n""" % (encodeint (self.number - 1) ,str) return str class KeySignature: @@ -462,14 +463,19 @@ class Frame: # do grace notes. lastch = None + in_grace = 0 for c in self.chords: if c.grace and (lastch == None or (not lastch.grace)): c.chord_prefix = r'\grace {' + c.chord_prefix + in_grace = 1 elif not c.grace and lastch and lastch.grace: lastch.chord_suffix = lastch.chord_suffix + ' } ' - + in_grace = 0 + lastch = c - + + if lastch and in_grace: + lastch.chord_suffix += '}' def dump (self): @@ -492,7 +498,7 @@ class Frame: sys.stderr.write ("""\nHuh? Going backwards in frame no %d, start/end (%d,%d)""" % (self.number, self.start, self.end)) left = (0,1) if left[0]: - str = str + rat_to_lily_duration (left) + str = str + rational_to_lily_skip (left) str = str + ' | \n' return str @@ -559,7 +565,7 @@ class Staff: str = string.join (map (lambda x: '(volta %s)' % x, strs)) - e = e + ' \\property Score.repeatCommands = #\'(%s) ' % str + e = e + ' \\set Score.repeatCommands = #\'(%s) ' % str if g.force_break: e = e + ' \\break ' @@ -569,7 +575,7 @@ class Staff: last_clef = m.clef if e: if gap <> (0,1): - k = k +' ' + rat_to_lily_duration (gap) + '\n' + k = k +' ' + rational_to_lily_skip (gap) + '\n' gap = (0,1) k = k + e @@ -578,7 +584,7 @@ class Staff: if 'stop' in g.repeats: k = k + ' \\bar ":|" ' - k = '%sglobal = \\notes { %s }\n\n ' % (self.staffid (), k) + k = '%sglobal = { %s }\n\n ' % (self.staffid (), k) return k def dump (self): @@ -605,7 +611,7 @@ class Staff: if fr: first_frame = fr if gap <> (0,1): - laystr = laystr +'} %s {\n ' % rat_to_lily_duration (gap) + laystr = laystr +'} %s {\n ' % rational_to_lily_skip (gap) gap = (0,1) laystr = laystr + fr.dump () else: @@ -617,7 +623,7 @@ class Staff: % (self.number, m.number)) if first_frame: l = self.layerid (x) - laystr = '%s = \\notes { { %s } }\n\n' % (l, laystr) + laystr = '%s = { { %s } }\n\n' % (l, laystr) str = str + laystr layerids.append (l) @@ -813,7 +819,7 @@ Return: (value, rest-of-STR) return (string.atoi (dec), str) else: - sys.stderr.write ("Can't convert `%s'\n" % str) + sys.stderr.write ("can't convert `%s'\n" % str) return (None, str) @@ -1125,7 +1131,8 @@ class Etf_file: sys.stderr.write ("\nLyrics found; edit to use \\addlyrics to couple to a staff\n") if staffs: - str = str + '\\score { << %s >> } ' % string.join (staffs) + str += '\\version "2.3.25"\n' + str = str + '<<\n %s\n>> } ' % string.join (staffs) return str @@ -1158,7 +1165,9 @@ 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-lilypond@gnu.org. +Report bugs via + + http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs Written by Han-Wen Nienhuys . @@ -1171,7 +1180,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--2004 by Han-Wen Nienhuys +Copyright (c) 2000--2005 by Han-Wen Nienhuys """ % version)