From d4e1cf3b24ad546d05a490ad1b07be45ea230e44 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 29 Oct 2004 10:16:20 +0000 Subject: [PATCH] *** empty log message *** --- ChangeLog | 15 +++++++++ Documentation/user/converters.itely | 4 ++- Documentation/user/notation.itely | 3 ++ scripts/abc2ly.py | 47 +++++++++++++++-------------- scripts/etf2ly.py | 30 ++++++++++-------- scripts/midi2ly.py | 4 +-- scripts/mup2ly.py | 3 +- 7 files changed, 68 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 069a83945c..699cb234e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,21 @@ 2004-10-29 Han-Wen Nienhuys + * Documentation/user/notation.itely (Automatic note splitting): + note about lyrics. + + * Documentation/user/converters.itely (Invoking convert-ly): note + about version numbers. + + * scripts/abc2ly.py (dump_score): revise lyric dumping + + * scripts/mup2ly.py (pre_processor_commands): always open file. + + * scripts/etf2ly.py (Frame.calculate): always close \grace. + (Etf_file.dump): add \version + + * VERSION: 2.3.25 released. + * lily/scm-option.cc: add 'resolution to ly:get-option argument list. diff --git a/Documentation/user/converters.itely b/Documentation/user/converters.itely index 52e44729cd..28553b86b9 100644 --- a/Documentation/user/converters.itely +++ b/Documentation/user/converters.itely @@ -66,7 +66,9 @@ The following options can be given: Print usage help. @end table - +convert-ly always converts up to the last syntax change handled by +it. This means that the @code{\version} number left in the file is +usually lower than the version of convert-ly itself. @refbugs diff --git a/Documentation/user/notation.itely b/Documentation/user/notation.itely index 0c24d9d39c..ca8228a6b4 100644 --- a/Documentation/user/notation.itely +++ b/Documentation/user/notation.itely @@ -821,6 +821,9 @@ Not all durations (especially those containing tuplets) can be represented exactly with normal notes and dots, but the engraver will not insert tuplets. +The @internalsref{Completion_heads_engraver} can be combined with +@code{\lyricsto} or @code{\addlyrics}. + @seealso Examples: @inputfileref{input/regression,completion-heads.ly}. diff --git a/scripts/abc2ly.py b/scripts/abc2ly.py index 53a5f61b3f..68200e785e 100644 --- a/scripts/abc2ly.py +++ b/scripts/abc2ly.py @@ -102,7 +102,6 @@ nobarlines = 0 global_key = [0] * 7 # UGH names = ["One", "Two", "Three"] DIGITS='0123456789' -alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ" HSPACE=' \t' midi_specs = '' @@ -112,6 +111,9 @@ def error (msg): if strict: sys.exit (1) + +def alphabet (i): + return chr (i + ord('A')) def check_clef(s): if not s: @@ -164,12 +166,10 @@ def select_voice (name, rol): elif keyword == "name": value = re.sub ('\\\\','\\\\\\\\', value) ## < 2.2 - ##voices_append ("\\property Staff.instrument = %s\n" % value ) voices_append ("\\set Staff.instrument = %s\n" % value ) __main__.part_names = 1 elif keyword == "sname" or keyword == "snm": - ##voices_append ("\\property Staff.instr = %s\n" % value ) voices_append ("\\set Staff.instr = %s\n" % value ) else: break @@ -185,7 +185,7 @@ def dump_header (outf,hdr): def dump_lyrics (outf): if (len(lyrics)): - outf.write("\n\\score\n{\n \\context Lyrics\n <<\n") + outf.write("\n\\score\n{\n \\lyrics\n <<\n") for i in range (len (lyrics)): outf.write ( lyrics [i]) outf.write ("\n") @@ -196,7 +196,6 @@ def dump_default_bar (outf): Nowadays abc2ly outputs explicits barlines (?) """ ## < 2.2 - ##outf.write ("\n\\property Score.defaultBarType = \"empty\"\n") outf.write ("\n\\set Score.defaultBarType = \"empty\"\n") @@ -205,12 +204,12 @@ def dump_slyrics (outf): ks.sort () for k in ks: if re.match('[1-9]', k): - m = alphabet[string.atoi(k)] + m = chr(string.atoi(k) + 'A') else: m = k for i in range (len(slyrics[voice_idx_dict[k]])): - l=alphabet[i] - outf.write ("\nwords%sV%s = {" % (m, l)) + l= alphabet(i) + outf.write ("\nwords%sV%s = \lyricmode {" % (m, l)) outf.write ("\n" + slyrics [voice_idx_dict[k]][i]) outf.write ("\n}") @@ -220,7 +219,7 @@ def dump_voices (outf): ks.sort () for k in ks: if re.match ('[1-9]', k): - m = alphabet[string.atoi(k)] + m = chr(string.atoi(k) + 'A') else: m = k outf.write ("\nvoice%s = {" % m) @@ -253,7 +252,9 @@ def try_parse_q(a): sys.stderr.write("abc2ly: Warning, unable to parse Q specification: %s\n" % a) def dump_score (outf): - outf.write (r"""\score{ + outf.write (r""" + +\score{ << """) @@ -261,28 +262,28 @@ def dump_score (outf): ks.sort () for k in ks: if re.match('[1-9]', k): - m = alphabet[string.atoi(k)] + m = alphabet (string.atoi(k)) else: m = k if k == 'default' and len (voice_idx_dict) > 1: break - if len ( slyrics [voice_idx_dict[k]] ): - outf.write ("\n \\addlyrics") outf.write ("\n\t\\context Staff=\"%s\"\n\t{\n" %k ) if k != 'default': outf.write ("\t \\voicedefault\n") outf.write ("\t \\voice%s " % m) outf.write ("\n\t}\n") - if len ( slyrics [voice_idx_dict[k]] ): - outf.write ("\n\t\\context Lyrics=\"%s\" \n\t<<\t" % k) + + l = ord( 'A' ) + for lyrics in slyrics [voice_idx_dict[k]]: + outf.write ("\n\t\\addlyrics { \n") if re.match('[1-9]',k): - m = alphabet[string.atoi(k)] + m = alphabet (string.atoi(k)) else: m = k - for i in range (len(slyrics[voice_idx_dict[k]])): - l=alphabet[i] - outf.write("\n\t { \\words%sV%s }" % ( m, l) ) - outf.write ( "\n\t>>\n" ) + + outf.write ( " \\words%sV%s } " % ( m, chr (l)) ) + l += 1 + outf.write ("\n >>") outf.write ("\n\t\\layout {\n") if part_names: @@ -644,12 +645,12 @@ def try_parse_header_line (ln, state): if a == 'C': if not state.common_time: state.common_time = 1 - voices_append ("\\property Staff.TimeSignature \\override #\'style = #'C\n") + voices_append (" \\override Staff.TimeSignature #\'style = #'C\n") a = '4/4' if a == 'C|': if not state.common_time: state.common_time = 1 - voices_append ("\\property Staff.TimeSignature \\override #\'style = #'C\n") + voices_append ("\\override Staff.TimeSignature #\'style = #'C\n") a = '2/2' if not length_specified: set_default_len_from_time_sig (a) @@ -1387,6 +1388,8 @@ for f in files: sys.stderr.write ('lilypond output to: `%s\'...' % out_filename) outf = open (out_filename, 'w') + outf.write ('\\version "2.3.25"\n') + # dump_global (outf) dump_header (outf, header) dump_slyrics (outf) diff --git a/scripts/etf2ly.py b/scripts/etf2ly.py index 599ddfccb3..2d0ea2dcba 100644 --- a/scripts/etf2ly.py +++ b/scripts/etf2ly.py @@ -109,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)) @@ -119,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): @@ -137,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 @@ -395,7 +395,7 @@ class Verse: str = str + ' ' * 4 + line + '\n' line = '' - str = """\nverse%s = \\lyricmode {\n %s}\n""" % (encodeint (self.number - 1) ,str) + str = """\nverse%s = \\lyricmode {\n %s }\n""" % (encodeint (self.number - 1) ,str) return str class KeySignature: @@ -463,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): @@ -493,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 @@ -570,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 @@ -606,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: @@ -618,7 +623,7 @@ class Staff: % (self.number, m.number)) if first_frame: l = self.layerid (x) - laystr = '%s = { { %s } }\n\n' % (l, laystr) + laystr = '%s = { { %s } }\n\n' % (l, laystr) str = str + laystr layerids.append (l) @@ -1126,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 diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py index c92451dcc5..a5bb08a114 100644 --- a/scripts/midi2ly.py +++ b/scripts/midi2ly.py @@ -982,8 +982,9 @@ def convert_midi (f, o): tag = '%% Lily was here -- automatically converted by %s from %s' % ( program_name, f) + s = '' - s = tag + '\n\n' + s = tag + '\n\\version "2.3.25"\n\n' for i in range (len (tracks)): s = s + dump_track (tracks[i], i) @@ -1083,7 +1084,6 @@ if not files or files[0] == '-': for f in files: - g = f g = strip_extension (g, '.midi') g = strip_extension (g, '.mid') diff --git a/scripts/mup2ly.py b/scripts/mup2ly.py index 98ba97c589..cb62a5faab 100644 --- a/scripts/mup2ly.py +++ b/scripts/mup2ly.py @@ -1295,7 +1295,8 @@ for f in files: h = sys.stdin elif f and not os.path.isfile (f): f = strip_extension (f, '.mup') + '.mup' - h = open (f) + + h = open (f) progress ( _("Processing `%s'..." % f)) raw_lines = h.readlines () p = Pre_processor (raw_lines) -- 2.39.2