From 8201858f6cada5988a24a3bd4e6bde5bbda50e89 Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 27 Mar 2002 00:34:22 +0000 Subject: [PATCH] lilypond-1.3.115 --- Documentation/user/GNUmakefile | 5 +- input/test/coriolan-margin.ly | 21 ++- input/test/figured-bass.ly | 26 +++ input/test/time.ly | 280 +++++++++++++++---------------- lily/instrument-name-engraver.cc | 23 ++- scm/lily.scm | 1 + scm/translator-properties.scm | 4 +- scripts/abc2ly.py | 135 ++++++++++++--- 8 files changed, 311 insertions(+), 184 deletions(-) create mode 100644 input/test/figured-bass.ly diff --git a/Documentation/user/GNUmakefile b/Documentation/user/GNUmakefile index bff671da11..906ea48fb5 100644 --- a/Documentation/user/GNUmakefile +++ b/Documentation/user/GNUmakefile @@ -18,7 +18,7 @@ PS_FILES = $(DVI_FILES:.dvi=.ps) $(OUTDOC_FILES:.doc=.ps) $(OUTTEX_FILES:.tex=. PS_GZ_FILES= $(addsuffix .gz, $(PS_FILES)) -INFO_FILES = $(addprefix $(outdir)/, lilypond.info lilypond-internals.info) +# INFO_FILES = $(addprefix $(outdir)/, lilypond.info lilypond-internals.info) STEPMAKE_TEMPLATES=tex texinfo documentation LOCALSTEPMAKE_TEMPLATES=lilypond ly @@ -32,11 +32,12 @@ ps: $(PS_FILES) # Cancel default info rule $(outdir)/%.info: $(outdir)/%.texi +default: + # info is now built by default via texinfo-rules # we must build them by default, otherwise they get built during make install info: $(INFO_FILES) -default: DEEP_HTML_FILES = $(outdir)/lilypond/lilypond.html $(outdir)/lilypond-internals/lilypond-internals.html diff --git a/input/test/coriolan-margin.ly b/input/test/coriolan-margin.ly index 30bb13b080..26bd470d44 100644 --- a/input/test/coriolan-margin.ly +++ b/input/test/coriolan-margin.ly @@ -1,3 +1,6 @@ + +#(define raisedflat '((raise . 0.4) (music (named "accidentals--1")))) + flauti = \notes \relative c' { \property Staff.instrument = #"2 Flauti" \property Staff.instr = #"Fl." @@ -16,8 +19,8 @@ oboi = \notes \relative c' { } clarinetti = \notes \relative c' { - \property Staff.instrument = #"2 Clarinetti\n(B\\textflat)" - \property Staff.instr = #"Cl.\n(B\\textflat)" + \property Staff.instrument = #`(lines "2 Clarinetti" (rows "(B" ,raisedflat ")")) + \property Staff.instr = #`(lines "Cl." (rows "(B" ,raisedflat ")")) c1 c } @@ -29,21 +32,21 @@ fagotti = \notes \relative c' { } corni = \notes \relative c' { - \property Staff.instrument = #"2 Corni\n(E\\textflat)" - \property Staff.instr = #"Cor.\n(E\\textflat)" + \property Staff.instrument = #`(lines "2 Corni" (rows "(E" ,raisedflat ")")) + \property Staff.instr = #`(lines "Cor." (rows "(E" ,raisedflat ")")) c1 c } trombe = \notes \relative c' { - \property Staff.instrument = #"2 Trombe\n(C)" - \property Staff.instr = #"Tbe.\n(C)" + \property Staff.instrument = #'(lines "2 Trombe" "(C)") + \property Staff.instr = #'(lines "Tbe." "(C)") c1 c } timpani = \notes \relative c' { - \property Staff.instrument = #"Timpani\n(C-G)" + \property Staff.instrument = #'(lines "Timpani" "(C-G)") \property Staff.instr = #"Timp." c1 c @@ -69,8 +72,8 @@ viola = \notes \relative c' { } violoncello = \notes \relative c' { - \property Staff.instrument = #"Violoncello\ne\nContrabasso" - \property Staff.instr = #"Vc.\nCb." + \property Staff.instrument = #'(lines "Violoncello" "e" "Contrabasso") + \property Staff.instr = #'(lines "Vc." "Cb.") c1 c } diff --git a/input/test/figured-bass.ly b/input/test/figured-bass.ly new file mode 100644 index 0000000000..f019ea5327 --- /dev/null +++ b/input/test/figured-bass.ly @@ -0,0 +1,26 @@ +% Example of figured bass, using text scripts. +% (An alternative is to use a lyrics line if you want the figures +% aligned vertically.) + +\version "1.3.112"; + +% Scheme macros for accidentals. Note how they can be combined +% with other strings, for example in: d^#`(rows ,sharp "4") + +#(define sharp '((raise . 0.2) (music (named "accidentals-1")))) +#(define natural '((raise . 0.2) (music (named "accidentals-0")))) +#(define flat '((raise . 0.2) (music (named "accidentals--1")))) + + +\score{ + \notes \relative c'{ + \clef bass; + + c^"5" d^#natural g,^"7 6" [a8 e] | + fis4^"7 6" [g8 d] e4^"7 6" [f?8 c] | + [d^#sharp d b g][c^"7" c^"5" a^"6" f] | + [bes^"7" bes^"5" g^"6" e] a4^#sharp d^"6" ~ | + d^#`(rows ,sharp "4") c^"6" d e^#sharp | + } +} + diff --git a/input/test/time.ly b/input/test/time.ly index d97e700df6..0731002786 100644 --- a/input/test/time.ly +++ b/input/test/time.ly @@ -1,145 +1,145 @@ \score { \context Voice \notes\relative c { - \property Staff.textEmptyDimension = 1 - \property Voice.textEmptyDimension = 1 - \property Staff.timeSignatureStyle = "C" - \time 1/1; - c''1^"timeSignatureStyle = \"C\"" - \time 2/2; - c1 - \time 2/4; - c2 - \time 3/4; - c2. - \time 4/4; - c1 - \time 5/4; - c2. c2 - \time 6/4; - c1. - \time 3/2; - c1. - \time 7/4; - c1 c2. - \time 8/4; - c\breve - \time 9/4; - c2. c2. c2. - \break - \property Staff.timeSignatureStyle = "old" - \time 1/1; - c1^"timeSignatureStyle = \"old\"" - \time 2/2; - c1 - \time 2/4; - c2 - \time 3/4; - c2. - \time 4/4; - c1 - \time 5/4; - c2. c2 - \time 6/4; - c1. - \time 3/2; - c1. - \time 7/4; - c1 c2. - \time 8/4; - c\breve - \time 9/4; - c2. c2. c2. - \time 6/8; - c2. - \time 9/8; - c4. c4. c4. - \break - \property Staff.timeSignatureStyle = "" - \time 1/1; - c1^"timeSignatureStyle = \"\"" - \time 2/2; - c1 - \time 2/4; - c2 - \time 3/4; - c2. - \time 4/4; - c1 - \time 5/4; - c2. c2 - \time 6/4; - c1. - \time 3/2; - c1. - \time 7/4; - c1 c2. - \time 8/4; - c\breve - \time 9/4; - c2. c2. c2. - \break - \property Staff.timeSignatureStyle = "1" - \time 1/1; - c1^"timeSignatureStyle = \"1\"" - \time 2/2; - c1 - \time 2/4; - c2 - \time 3/4; - c2. - \time 4/4; - c1 - \time 5/4; - c2. c2 - \time 6/4; - c1. - \time 3/2; - c1. - \time 7/4; - c1 c2. - \time 8/4; - c\breve - \time 9/4; - c2. c2. c2. - \break - \property Staff.textalignment = \center - \property Staff.timeSignatureStyle = "old9/8" - \time 1/1; - c1^"old9/8" - \property Staff.timeSignatureStyle = "old6/8" - \time 1/1; - c1^"old6/8" - \property Staff.timeSignatureStyle = "old6/8alt" - \time 1/1; - c1^"old6/8alt" - \property Staff.timeSignatureStyle = "old9/4" - \time 1/1; - c1^"old9/4" - \property Staff.timeSignatureStyle = "old6/4" - \time 1/1; - c1^"old6/4" - \property Staff.timeSignatureStyle = "old3/2" - \time 1/1; - c1^"old3/2" - \property Staff.timeSignatureStyle = "old4/4" - \time 1/1; - c1^"old4/4" - \property Staff.timeSignatureStyle = "old2/2" - \time 1/1; - c1^"old2/2" - \property Staff.timeSignatureStyle = "old2/4" - \time 1/1; - c1^"old2/4" - \property Staff.timeSignatureStyle = "old4/8" - \time 1/1; - c1^"old4/8" - \property Staff.timeSignatureStyle = "C4/4" - \time 1/1; - c1^"C4/4" - \property Staff.timeSignatureStyle = "C2/2" - \time 1/1; - c1^"C2/2" - + \property Staff.TimeSignature \override #'style = #'C + \time 1/1; + c''1^"TimeSignature style = \#'C" + \time 2/2; + c1 + \time 2/4; + c2 + \time 3/4; + c2. + \time 4/4; + c1 + \time 5/4; + c2. c2 + \time 6/4; + c1. + \time 3/2; + c1. + \time 7/4; + c1 c2. + \time 8/4; + c\breve + \time 9/4; + c2. c2. c2. + \break + \property Staff.TimeSignature \set #'style = #'old + \time 1/1; + c1^"TimeSignature style = \#'old" + \time 2/2; + c1 + \time 2/4; + c2 + \time 3/4; + c2. + \time 4/4; + c1 + \time 5/4; + c2. c2 + \time 6/4; + c1. + \time 3/2; + c1. + \time 7/4; + c1 c2. + \time 8/4; + c\breve + \time 9/4; + c2. c2. c2. + \time 6/8; + c2. + \time 9/8; + c4. c4. c4. + \break + % Lilypond doesn't understand 'default => it does what you want + \property Staff.TimeSignature \set #'style = #'default + \time 1/1; + c1^"TimeSignature style = \#'default" + \time 2/2; + c1 + \time 2/4; + c2 + \time 3/4; + c2. + \time 4/4; + c1 + \time 5/4; + c2. c2 + \time 6/4; + c1. + \time 3/2; + c1. + \time 7/4; + c1 c2. + \time 8/4; + c\breve + \time 9/4; + c2. c2. c2. + \break + % If the style starts with a '1', you get this style + \property Staff.TimeSignature \set #'style = #'1style + \time 1/1; + c1^"TimeSignature style = \#'1xxx" + \time 2/2; + c1 + \time 2/4; + c2 + \time 3/4; + c2. + \time 4/4; + c1 + \time 5/4; + c2. c2 + \time 6/4; + c1. + \time 3/2; + c1. + \time 7/4; + c1 c2. + \time 8/4; + c\breve + \time 9/4; + c2. c2. c2. + \break + \property Staff.TextScript \override #'self-alignment-X = #1 + \property Staff.TimeSignature \set #'style = #'old9/8 + \time 1/1; + c1^"old9/8" + \property Staff.TimeSignature \set #'style = #'old6/8 + \time 1/1; + c1^"old6/8" + \property Staff.TimeSignature \set #'style = #'old6/8alt + \time 1/1; + c1^"old6/8alt" + \property Staff.TimeSignature \set #'style = #'old9/4 + \time 1/1; + c1^"old9/4" + \property Staff.TimeSignature \set #'style = #'old6/4 + \time 1/1; + c1^"old6/4" + \property Staff.TimeSignature \set #'style = #'old3/2 + \time 1/1; + c1^"old3/2" + \property Staff.TimeSignature \set #'style = #'old4/4 + \time 1/1; + c1^"old4/4" + \property Staff.TimeSignature \set #'style = #'old2/2 + \time 1/1; + c1^"old2/2" + \property Staff.TimeSignature \set #'style = #'old2/4 + \time 1/1; + c1^"old2/4" + \property Staff.TimeSignature \set #'style = #'old4/8 + \time 1/1; + c1^"old4/8" + \property Staff.TimeSignature \set #'style = #'C4/4 + \time 1/1; + c1^"C4/4" + \property Staff.TimeSignature \set #'style = #'C2/2 + \time 1/1; + c1^"C2/2" + } \paper { } \midi { } diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc index cac8ec76d4..e903781f7e 100644 --- a/lily/instrument-name-engraver.cc +++ b/lily/instrument-name-engraver.cc @@ -47,17 +47,26 @@ Instrument_name_engraver::stop_translation_timestep () } } +/* + FIXME: use different mechanics, and use a markup-p function? + */ void Instrument_name_engraver::create_text (SCM txt) { if(!text_) { text_ = new Item (get_property ("InstrumentName")); - text_->set_grob_property ("text", txt); - + if (txt != SCM_EOL) + { + text_->set_grob_property ("text", txt); + } + else if (text_->get_grob_property ("text") == SCM_EOL) + { + return; + } if (delim_) - text_->set_parent (delim_, Y_AXIS); - + text_->set_parent (delim_, Y_AXIS); + announce_grob (text_,0); } } @@ -72,10 +81,10 @@ Instrument_name_engraver::acknowledge_grob (Grob_info i) if (now_mom () > Moment (0)) s = get_property ("instr"); - if (gh_string_p (s)) - { + // if (gh_string_p (s)) + // { create_text (s); - } + // } } if (Align_interface::has_interface (i.elem_l_) diff --git a/scm/lily.scm b/scm/lily.scm index 7243adeae8..228c6d3a78 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -27,6 +27,7 @@ (and (pair? x) (number? (car x)) (number? (cdr x)))) (define (boolean-or-symbol? x) (or boolean? x) (or symbol? x)) (define (number-or-string? x) (or (number? x) (string? x))) +(define (list-or-string? x) (or (list? x) (string? x))) (define markup? (lambda (x) (or (string? x) (list? x)))) diff --git a/scm/translator-properties.scm b/scm/translator-properties.scm index dec53c5905..751081619a 100644 --- a/scm/translator-properties.scm +++ b/scm/translator-properties.scm @@ -125,8 +125,8 @@ remembered for the duration of a measure. ") (translator-property-description 'graceAccidentalSpace number? "amount space to alot for an accidental") (translator-property-description 'graceAlignPosition dir? "put the grace note before or after the main note?") -(translator-property-description 'instr string? "see @code{instrument}") -(translator-property-description 'instrument string? " If @code{Instrument_name_engraver} +(translator-property-description 'instr list-or-string? "see @code{instrument}") +(translator-property-description 'instrument list-or-string? " If @code{Instrument_name_engraver} @cindex Instrument_name_engraver is added to the Staff translator, then the @code{instrument} property diff --git a/scripts/abc2ly.py b/scripts/abc2ly.py index b31a56bc3c..8cab59b86a 100644 --- a/scripts/abc2ly.py +++ b/scripts/abc2ly.py @@ -30,7 +30,8 @@ # # Barring now preserved between ABC and lilypond # the default placement for text in abc is above the staff. -# %%LY now supported. +# %%LY now supported. +# \breve and \longa supported. # Limitations # @@ -67,10 +68,12 @@ UNDEF = 255 state = UNDEF voice_idx_dict = {} header = {} +header['footnotes'] = '' lyrics = [] slyrics = [] voices = [] state_list = [] +repeat_state = [0] * 8 current_voice_idx = -1 current_lyric_idx = -1 lyric_idx = -1 @@ -87,7 +90,14 @@ HSPACE=' \t' def check_clef(s): if not s: return '' - if re.match('^treble', s): + if re.match('-8va', s) or re.match('treble8', s): + # treble8 is used by abctab2ps; -8va is used by barfly, + # and by my patch to abc2ps. If there's ever a standard + # about this we'll support that. + s = s[4:] + state.base_octave = -1 + voices_append("\\clef \"G_8\";\n") + elif re.match('^treble', s): s = s[6:] if re.match ('^-8', s): s = s[2:] @@ -96,10 +106,6 @@ def check_clef(s): else: state.base_octave = 0 voices_append("\\clef treble;\n") - elif re.match('^-8va', s): - s = s[4:] - state.base_octave = -1 - voices_append("\\clef \"G_8\";\n") elif re.match('^alto', s): s = s[4:] state.base_octave = -1 @@ -172,12 +178,20 @@ def dump_slyrics (outf): outf.write ("\n}") def dump_voices (outf): + global doing_alternative, in_repeat ks = voice_idx_dict.keys() ks.sort () for k in ks: outf.write ("\nvoice%s = \\notes {" % k) dump_default_bar(outf) + if repeat_state[voice_idx_dict[k]]: + outf.write("\n\\repeat volta 2 {") outf.write ("\n" + voices [voice_idx_dict[k]]) + if not using_old: + if doing_alternative[voice_idx_dict[k]]: + outf.write("}") + if in_repeat[voice_idx_dict[k]]: + outf.write("}") outf.write ("\n}") def dump_score (outf): @@ -308,13 +322,16 @@ key_lookup = { # abc to lilypond key mode names 'm' : 'minor', 'min' : 'minor', 'maj' : 'major', + 'major' : 'major', 'phr' : 'phrygian', 'ion' : 'ionian', 'loc' : 'locrian', 'aeo' : 'aeolian', 'mix' : 'mixolydian', + 'mixolydian' : 'mixolydian', 'lyd' : 'lydian', - 'dor' : 'dorian' + 'dor' : 'dorian', + 'dorian' : 'dorian' } def lily_key (k): @@ -431,7 +448,7 @@ def header_append (key, a): s = '' if header.has_key (key): s = header[key] + "\n" - header [key] = s + a + header [key] = s + a def wordwrap(a, v): linelen = len (v) - string.rfind(v, '\n') @@ -450,9 +467,16 @@ def stuff_append (stuff, idx, a): def voices_append(a): if current_voice_idx < 0: select_voice ('default', '') - stuff_append (voices, current_voice_idx, a) +def repeat_prepend(): + global repeat_state + if current_voice_idx < 0: + select_voice ('default', '') + if not using_old: + repeat_state[current_voice_idx] = 't' + + def lyrics_append(a): a = re.sub ( '#', '\\#', a) # latex does not like naked #'s a = re.sub ( '"', '\\"', a) # latex does not like naked "'s @@ -462,14 +486,13 @@ def lyrics_append(a): # break lyrics to words and put "'s around words containing numbers and '"'s def fix_lyric(str): ret = '' - while str != '': m = re.match('[ \t]*([^ \t]*)[ \t]*(.*$)', str) if m: word = m.group(1) str = m.group(2) word = re.sub('"', '\\"', word) # escape " - if re.match('.*[0-9"]', word): + if re.match('.*[0-9"\(]', word): word = re.sub('_', ' ', word) # _ causes probs inside "" ret = ret + '\"' + word + '\" ' else: @@ -485,7 +508,7 @@ def slyrics_append(a): a = re.sub ( '~', '_', a) # ~ to space('_') a = re.sub ( '\*', '_ ', a) # * to to space a = re.sub ( '#', '\\#', a) # latex does not like naked #'s - if re.match('.*[0-9"]', a): # put numbers and " into quoted string + if re.match('.*[0-9"\(]', a): # put numbers and " and ( into quoted string a = fix_lyric(a) a = re.sub ( '$', ' ', a) # insure space between lines __main__.lyric_idx = lyric_idx + 1 @@ -546,6 +569,8 @@ def try_parse_header_line (ln, state): else: __main__.global_key = compute_key (a)# ugh. voices_append ('\\key %s \\major;' % lily_key(a)) + if g == 'N': # Notes + header ['footnotes'] = header['footnotes'] + '\\\\\\\\' + a if g == 'O': # Origin header ['origin'] = a if g == 'X': # Reference Number @@ -628,7 +653,12 @@ def duration_to_lilypond_duration (multiply_tup, defaultlen, dots): # (num / den) / defaultlen < 1/base while base * multiply_tup[0] < multiply_tup[1]: base = base * 2 - return '%d%s' % ( base, '.'* dots) + if base == 1: + if (multiply_tup[0] / multiply_tup[1]) == 2: + base = '\\breve' + if (multiply_tup[0] / multiply_tup[1]) == 4: + base = '\longa' + return '%s%s' % ( base, '.'* dots) class Parser_state: def __init__ (self): @@ -733,7 +763,6 @@ artic_tbl = { } def try_parse_articulation (str, state): - while str and artic_tbl.has_key(str[:1]): state.next_articulation = state.next_articulation + artic_tbl[str[:1]] if not artic_tbl[str[:1]]: @@ -879,6 +908,11 @@ def try_parse_guitar_chord (str, state): if str[:1] =='"': str = str[1:] gc = '' + if str[0] == '_' or (str[0] == '^'): + position = str[0] + str = str[1:] + else: + position = '^' while str and str[0] != '"': gc = gc + str[0] str = str[1:] @@ -886,7 +920,7 @@ def try_parse_guitar_chord (str, state): if str: str = str[1:] gc = re.sub('#', '\\#', gc) # escape '#'s - state.next_articulation = ("^\"%s\"" % gc) + state.next_articulation + state.next_articulation = ("%c\"%s\"" % (position ,gc)) + state.next_articulation return str def try_parse_escape (str): @@ -907,7 +941,7 @@ def try_parse_escape (str): # :: left-right repeat # |1 volta 1 # |2 volta 2 -bar_dict = { +old_bar_dict = { '|]' : '|.', '||' : '||', '[|' : '||', @@ -919,23 +953,71 @@ bar_dict = { ':|2' : ':|', '|' : '|' } +bar_dict = { + '|]' : '\\bar "|.";', + '||' : '\\bar "||";', + '[|' : '\\bar "||";', + ':|' : '}', + '|:' : '\\repeat volta 2 {', + '::' : '} \\repeat volta 2 {', + '|1' : '} \\alternative{{', + '|2' : '} {', + ':|2' : '} {', + '|' : '\\bar "|";' + } warn_about = ['|:', '::', ':|', '|1', ':|2', '|2'] +alternative_opener = ['|1', '|2', ':|2'] +repeat_ender = ['::', ':|'] +repeat_opener = ['::', '|:'] +in_repeat = [''] * 8 +doing_alternative = [''] * 8 +using_old = '' def try_parse_bar (str,state): + global in_repeat, doing_alternative, using_old + do_curly = '' bs = None - + if current_voice_idx < 0: + select_voice ('default', '') # first try the longer one for trylen in [3,2,1]: if str[:trylen] and bar_dict.has_key (str[:trylen]): s = str[:trylen] - bs = "\\bar \"%s\";" % bar_dict[s] - if s in warn_about: - sys.stderr.write('Warning kludging for barline `%s\'\n' % s) + if using_old: + bs = "\\bar \"%s\";" % old_bar_dict[s] + else: + bs = "%s" % bar_dict[s] str = str[trylen:] - break + if s in alternative_opener: + if not in_repeat[current_voice_idx]: + using_old = 't' + bs = "\\bar \"%s\";" % old_bar_dict[s] + else: + doing_alternative[current_voice_idx] = 't' + if s in repeat_ender: + if not in_repeat[current_voice_idx]: + sys.stderr.write("Warning: inserting repeat to beginning of notes.\n") + repeat_prepend() + in_repeat[current_voice_idx] = '' + else: + if doing_alternative[current_voice_idx]: + do_curly = 't' + if using_old: + bs = "\\bar \"%s\";" % old_bar_dict[s] + else: + bs = bar_dict[s] + doing_alternative[current_voice_idx] = '' + in_repeat[current_voice_idx] = '' + if s in repeat_opener: + in_repeat[current_voice_idx] = 't' + if using_old: + bs = "\\bar \"%s\";" % old_bar_dict[s] + else: + bs = bar_dict[s] + break if str[:1] == '|': state.next_bar = '|\n' str = str[1:] @@ -949,7 +1031,9 @@ def try_parse_bar (str,state): if bs <> None: clear_bar_acc(state) voices_append (bs) - + if do_curly != '': + voices_append("} }") + do_curly = '' return str def try_parse_tie (str): @@ -1035,13 +1119,16 @@ def try_parse_comment (str): #non-western scales, it is necessary to be able to tell a translator that #the barlines should not affect its interpretation of the pitch. if (string.find(str,'nobarlines') > 0): - #debugging nobarlines = 1 elif str[0:3] == '%LY': p = string.find(str, 'voices') if (p > -1): voices_append(str[p+7:]) voices_append("\n") + p = string.find(str, 'slyrics') + if (p > -1): + slyrics_append(str[p+8:]) + #write other kinds of appending if we ever need them. return str @@ -1103,7 +1190,7 @@ def identify(): def help (): print r""" -Convert ABC to Lilypond. +Convert ABC to lilypond. Usage: abc2ly [OPTIONS]... ABC-FILE -- 2.39.5