From: Han-Wen Nienhuys Date: Tue, 23 Dec 2003 22:29:44 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: release/2.1.23~301 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fd58a98a46a3def26b80a895f1f7b81c92590fc3;p=lilypond.git *** empty log message *** --- diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 4678a6aaea..5822820de8 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -3114,7 +3114,6 @@ terminating too soon. The staff switches often do not end up in optimal places. For high quality output, staff switches should be specified manually. - @node Manual staff switches @subsection Manual staff switches @@ -3134,6 +3133,7 @@ current voice from its current staff to the Staff called @code{"down"}. + @node Pedals @subsection Pedals @cindex Pedals @@ -7535,11 +7535,10 @@ then you can use @end example @end itemize - The object description is an Scheme association -list. Since a Scheme list is a singly linked list, we can treat it as -a stack, and @code{\override} and @code{\revert} are push and pop -operations. The association list is stored in a normal context -property, hence +The object description is an Scheme association list. Since a Scheme +list is a singly linked list, we can treat it as a stack, and +@code{\override} and @code{\revert} are push and pop operations. The +association list is stored in a normal context property, hence @example \property Voice.NoteHead = #'() @end example @@ -7562,6 +7561,28 @@ Cyclic references in Scheme values for properties cause hangs and/or crashes. Reverting properties that are system defaults may also lead to crashes. +A property tweak of modifies a local copy of the object definition. +After such a tweak, the definition is independent of the objects in +enclosing contexts. For example + +@lilypond + \property Voice.Stem \set #'neutral-direction = #1 + b'8 + \property Staff.Stem \set #'thickness = #4.0 + b'16 + \new Voice { b'32 } +@end lilypond + +In this fragment, @code{neutral-direction} is tweaked. As a result, +the current @internalsref{Voice} gets a private version of the +@internalsref{Stem} object. The following tweak modifies the +definition at @internalsref{Staff} level. Since it a different +definition, the thickness of the @code{b'16} is unaffected. For the +third note, a new Voice is created, which inherits the new definition, +including the changed thickness, but excluding the new neutral +direction. + + @node Constructing a tweak @subsection Constructing a tweak @@ -7761,34 +7782,26 @@ center-line: The most common thing to change about the appearance of fonts is their size. The font size of any context can be easily changed by setting -the @code{fontSize} property for that context. Its value is an -integer: negative numbers make the font smaller, positive numbers -larger. An example is given below: +the @code{fontSize} property for that context. Its value is a number: +negative numbers make the font smaller, positive numbers larger. An +example is given below: @c @lilypond[fragment,relative=1,verbatim,quote] c4 c4 \property Voice.fontSize = #-1 f4 g4 @end lilypond -This command will set @code{font-relative-size} (see below), and does +This command will set @code{font-size} (see below), and does not change the size of variable symbols, such as beams or slurs. - One of the uses of @code{fontSize} is to get smaller symbol for cue notes. An elaborate example of those is in @inputfileref{input/test,cue-notes.ly}. @cindex magnification -The size of the font may be scaled with the object property -@code{font-magnification}. For example, @code{2.0} blows up all -letters by a factor 2 in both directions. @cindex cue notes -@cindex font size -@cindex size -@cindex symbol size -@cindex glyph size The font used for printing a object can be selected by setting @code{font-name}, e.g. @@ -7800,7 +7813,13 @@ The font used for printing a object can be selected by setting @noindent Any font can be used, as long as it is available to @TeX{}. Possible fonts include foreign fonts or fonts that do not belong to the -Computer Modern font family. +Computer Modern font family. The size of fonts selected in this way +can be changed with the @code{font-magnification} property. For +example, @code{2.0} blows up all letters by a factor 2 in both +directions. + +@cindex font size +@cindex font magnification Font selection for the standard fonts, @TeX{}'s Computer Modern fonts, can also be adjusted with a more fine-grained mechanism. By setting @@ -7808,6 +7827,7 @@ the object properties described below, you can select a different font; all three mechanisms work for every object that supports @code{font-interface}: + @table @code @item font-family is a symbol indicating the general class of the typeface. Supported are @@ -7825,22 +7845,6 @@ is a symbol indicating the series of the font. There are typically several font series for each font family and shape. Choices are @code{medium} and @code{bold}. -@item font-relative-size - is a number indicating the size relative the standard size. For example, - with 20pt staff height, relative size -1 corresponds to 16pt staff - height, and relative size +1 corresponds to 23 pt staff height. - - There are small differences in design between fonts designed for -different sizes, hence @code{font-relative-size} is preferred over -@code{font-magnification} for changing font sizes. - - -@item font-design-size -is a number indicating the design size of the font. - -This is a feature of the Computer Modern Font: each point size has a -slightly different design. Smaller design sizes are relatively wider, -which enhances readability. @end table For any of these properties, the value @code{*} (i.e. the symbol @@ -7854,6 +7858,20 @@ to override default setting, which are always present. For example: @cindex @code{font-style} +The font size is set by modifying the @code{font-size} property. Its +value is a number indicating the size relative to the standard size. +Each step up is an increase of approximately 12% of the font size. Six +steps is exactly a factor two. + +LilyPond has fonts in different design sizes: the music fonts for +smaller sizes are chubbier, while the text fonts are relatively wider. +Font size changes are achieved by scaling the design size that is +closest to the desired size. + +The @code{font-size} mechanism does not work for fonts selected +through @code{font-name}. These may be scaled with +@code{font-magnification}. + @refcommands The following commands set @code{fontSize} for the current voice. diff --git a/input/mutopia/F.Schubert/standchen.ly b/input/mutopia/F.Schubert/standchen.ly index 079577d4b5..5601bc1f60 100644 --- a/input/mutopia/F.Schubert/standchen.ly +++ b/input/mutopia/F.Schubert/standchen.ly @@ -42,7 +42,7 @@ instrument = "Piano" footer = "Mutopia-2001/04/27-xx" } -\version "1.9.8" +\version "2.1.1" dynamicUp = \property Voice.DynamicLineSpanner \override #'direction = #1 dynamicRevert = \property Voice.DynamicLineSpanner \revert #'direction @@ -382,7 +382,7 @@ global = \notes{ allLyrics = \lyrics { % maybe should be bigger by default, in grob-description.scm ? - \property Lyrics . LyricText \override #'font-relative-size = #1 + \property Lyrics . LyricText \override #'font-size = #2 \property Lyrics . LyricHyphen \override #'maximum-length = #1.5 \context LyricsVoice = "leise-1" { \lyricVerseOne \lyricVerseTwo diff --git a/input/mutopia/R.Schumann/romanze-op28-2.ly b/input/mutopia/R.Schumann/romanze-op28-2.ly index aeadb1f0d1..d58caec389 100644 --- a/input/mutopia/R.Schumann/romanze-op28-2.ly +++ b/input/mutopia/R.Schumann/romanze-op28-2.ly @@ -6,7 +6,7 @@ %% 19 is broken --hwn. %\include "paper19.ly" \include "paper16.ly" -\version "1.9.8" +\version "2.1.1" \header { title = "Romanzen" @@ -245,7 +245,7 @@ leftb = \notes \transpose c cis { \property PianoStaff.connectArpeggios = ##t \property PianoStaff.Arpeggio \override #'molecule-callback = \arpeggioBracket - \property PianoStaff.InstrumentName \set #'font-relative-size = #3 + \property PianoStaff.InstrumentName \set #'font-size = #6 \property PianoStaff.InstrumentName \set #'font-shape = #'italic \property PianoStaff.InstrumentName \set #'font-magnification = #3 @@ -255,7 +255,7 @@ leftb = \notes \transpose c cis { \clef G <<\global \context Voice=upv \righta >> } \context Staff = mid { - \property Staff.InstrumentName \set #'font-relative-size = #0 + \property Staff.InstrumentName \set #'font-size = #0 \property Staff.InstrumentName \set #'font-shape = #'upright \property Staff.InstrumentName \set #'font-magnification = #1 \property Staff.InstrumentName \set #'extra-offset = #'(0 . 6) diff --git a/input/mutopia/W.A.Mozart/mozart-hrn3-defs.ly b/input/mutopia/W.A.Mozart/mozart-hrn3-defs.ly index 2eb3ed2109..3ded8e1afa 100644 --- a/input/mutopia/W.A.Mozart/mozart-hrn3-defs.ly +++ b/input/mutopia/W.A.Mozart/mozart-hrn3-defs.ly @@ -4,7 +4,7 @@ longgrace = \property Voice.Stem \override #'stroke-style = #'() endlonggrace = \property Voice.Stem \revert #'stroke-style ritenuto = \markup { \italic "rit." } -\version "1.9.8" +\version "2.1.1" cresc = \notes { #(ly:export (make-event-chord (list (make-span-event 'CrescendoEvent START)))) @@ -40,7 +40,7 @@ stopGraceMusic= \sequential { restNumberThreshold = #1 RehearsalMark \override #'font-series = #'bold - RehearsalMark \override #'font-relative-size = #3 + RehearsalMark \override #'font-size = #6 Beam \override #'thickness = #0.6 Beam \override #'space-function = #(lambda (beam mult) 0.8) diff --git a/input/regression/accidental-single-double.ly b/input/regression/accidental-single-double.ly index d9c33e1e75..7d912da1ba 100644 --- a/input/regression/accidental-single-double.ly +++ b/input/regression/accidental-single-double.ly @@ -20,5 +20,6 @@ gisis'4 gis gisis ges | \thenotes } >> +\paper { raggedright = ##t } } diff --git a/input/regression/accidental-voice.ly b/input/regression/accidental-voice.ly index 5d500fdfc0..ee0654a914 100644 --- a/input/regression/accidental-voice.ly +++ b/input/regression/accidental-voice.ly @@ -57,4 +57,5 @@ voiceb = \notes \transpose c c' { >> \new NoteNames \apply #no-octaves \voiceb >> +\paper { raggedright = ##t } } diff --git a/input/regression/accidental.ly b/input/regression/accidental.ly index afadf3edfc..8f66fcb29b 100644 --- a/input/regression/accidental.ly +++ b/input/regression/accidental.ly @@ -14,4 +14,5 @@ foo = \notes\relative c'' { \key as \major dis4 dis dis!^"force" dis? } << \foo \context NoteNames \foo >> +\paper { raggedright = ##t } } diff --git a/input/template/piano-dynamics.ly b/input/template/piano-dynamics.ly index a6be85879c..33cc264801 100644 --- a/input/template/piano-dynamics.ly +++ b/input/template/piano-dynamics.ly @@ -1,4 +1,4 @@ -\version "1.9.8" +\version "2.1.1" \header { texidoc =" Template that puts dynamics on a separate line, so it is neatly @@ -48,7 +48,7 @@ pedal = \notes { \consists "Dynamic_engraver" \consists "Text_engraver" - TextScript \override #'font-relative-size = #1 + TextScript \override #'font-size = #2 TextScript \override #'font-shape = #'italic DynamicText \override #'extra-offset = #'(0 . 2.5) Hairpin \override #'extra-offset = #'(0 . 2.5) diff --git a/input/test/bagpipe.ly b/input/test/bagpipe.ly index 9a9d6048eb..dc38f91382 100644 --- a/input/test/bagpipe.ly +++ b/input/test/bagpipe.ly @@ -1,4 +1,4 @@ -\version "1.9.8" +\version "2.1.1" \header { texidoc = "@cindex Bagpipe Music diff --git a/input/test/bar-number-regular-interval.ly b/input/test/bar-number-regular-interval.ly index aa7f9ddbb4..f3c5bbb804 100644 --- a/input/test/bar-number-regular-interval.ly +++ b/input/test/bar-number-regular-interval.ly @@ -5,7 +5,7 @@ Bar numbers can also be printed at regular intervals. " } -\version "1.9.8" +\version "2.1.1" \score { \context Staff \notes \transpose c c' { @@ -13,7 +13,7 @@ Bar numbers can also be printed at regular intervals. \property Score.barNumberVisibility = #(every-nth-bar-number-visible 4) \property Score.BarNumber \override #'molecule-callback = #(make-molecule-boxer 0.1 0.25 0.25 Text_item::brew_molecule) - \property Score.BarNumber \override #'font-relative-size = #1 + \property Score.BarNumber \override #'font-size = #2 \repeat unfold 9 { c1 } \bar "|." } diff --git a/input/test/cautionaries.ly b/input/test/cautionaries.ly index f040cd3900..346bb340ba 100644 --- a/input/test/cautionaries.ly +++ b/input/test/cautionaries.ly @@ -1,4 +1,4 @@ -\version "1.9.8" +\version "2.1.1" \header{ texidoc="@cindex Cautionary Accidentals LilyPond can display cautionary accidentals in different ways. @@ -6,7 +6,7 @@ LilyPond can display cautionary accidentals in different ways. \score { \notes \context Staff \transpose c c'' { \key d \major % \property Staff.autoReminders = #'cautionary - \property Staff.Accidental \override #'font-relative-size = #0 + \property Staff.Accidental \override #'font-size = #0 1 cis?2 d? \property Staff.Accidental \override #'cautionary-style = #'smaller 1 cis?2 d? diff --git a/input/test/figured-bass-alternate.ly b/input/test/figured-bass-alternate.ly index e02ebf3d8a..75ef37575d 100644 --- a/input/test/figured-bass-alternate.ly +++ b/input/test/figured-bass-alternate.ly @@ -3,7 +3,7 @@ texidoc = "An alternate method to make bass figures is to use markup texts." } -\version "1.9.8" +\version "2.1.1" nat = \markup { \musicglyph #"accidentals-0" } sh = \markup { \smaller \raise #0.6 \musicglyph #"accidentals-1" } @@ -13,7 +13,7 @@ fl = \markup { \musicglyph #"accidentals--1" } \context Voice \notes { \clef bass \property Voice.TextScript \set #'font-family = #'number - \property Voice.TextScript \set #'font-relative-size = #-3 + \property Voice.TextScript \set #'font-size = #-6 \property Voice.TextScript \set #'baseline-skip = #1.4 dis4_\markup { 6 } diff --git a/lily/engraver-group-engraver.cc b/lily/engraver-group-engraver.cc index aa25efaa6e..5cab78639a 100644 --- a/lily/engraver-group-engraver.cc +++ b/lily/engraver-group-engraver.cc @@ -1,6 +1,6 @@ /* - engravergroup.cc -- implement Engraver_group_engraver - + engraver-group-engraver.cc -- implement Engraver_group_engraver + source file of the GNU LilyPond music typesetter (c) 1997--2003 Han-Wen Nienhuys @@ -32,38 +32,6 @@ Engraver_group_engraver::process_acknowledged_grobs_in_simple_children () } } -/* - - Done: eliminating useless broadcast/acknowledge - - -One cause for translation slowness: grob broadcasted/acknowledges - (b/a): every grob is b/a-ed to all peer-engravers and all -parent-engravers. This means that lots of (often) useless b/a is done -for large scores (the top-level engravers gets to know every detail of -every voice, thread, etc. Measurements indicate this is 10% of the - interpretation time: - - standchen - -old: (pre 1.5.13) 10.28 -new: 8.73 -speedup: 15 % - -Coriolan: - -new: 197.59 -old: 219.12 seconds -speedup: 10% - - -The cost of this B/A is # of useless engravers * cost of one ack, -which is rather low, since cost of one ack is only an interface check. -The cost of precomputing engraver lists has two elts: computing the -list itself, GC for the structure, looking up the list during the -acks. - -*/ SCM find_acknowledge_engravers (SCM gravlist, SCM meta); SCM find_accept_engravers (SCM gravlist, SCM music_descr); @@ -190,7 +158,8 @@ ENTER_DESCRIPTION(Engraver_group_engraver, /*****************/ -bool engraver_valid (Translator*tr, SCM ifaces) +bool +engraver_valid (Translator*tr, SCM ifaces) { SCM ack_ifs = scm_assoc (ly_symbol2scm ("interfaces-acked"), tr->translator_description()); ack_ifs = gh_cdr (ack_ifs); diff --git a/lily/font-interface.cc b/lily/font-interface.cc index d48e60a4c0..cddd1d033c 100644 --- a/lily/font-interface.cc +++ b/lily/font-interface.cc @@ -57,4 +57,4 @@ Font_interface::font_alist_chain (Grob*g) ADD_INTERFACE (Font_interface, "font-interface", "Any symbol that is typeset through fixed sets of glyphs (ie. fonts)", "font-magnification font font-series font-shape " - "font-family font-name font-design-size font-relative-size"); + "font-family font-name font-size"); diff --git a/lily/font-metric.cc b/lily/font-metric.cc index 90dcae5657..52933a503c 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -189,7 +189,7 @@ LY_DEFINE(ly_text_dimension,"ly:text-dimension", 2 , 0, 0, return gh_cons (ly_interval2scm (b[X_AXIS]), ly_interval2scm(b[Y_AXIS])); } - + Molecule Font_metric::get_char_molecule (int code) const { diff --git a/lily/font-select.cc b/lily/font-select.cc index 2890b629db..294ba8d3fc 100644 --- a/lily/font-select.cc +++ b/lily/font-select.cc @@ -1,27 +1,17 @@ -#include "paper-def.hh" -#include "font-interface.hh" -#include "warn.hh" - - -/* - TODO revise font handling. - +/* + font-select.cc -- implement property -> font_metric routines. -* relative sizes should relate to staff-space, eg. font-staff-space -= 1.2 ^ relative-size + source file of the GNU LilyPond music typesetter -* If a relative size is given, lily should magnify the closest -design size font to match that. (ie. fonts should have variable -scaling) + (c) 2003 Han-Wen Nienhuys -(this requires that fonts are stored as (filename , designsize)) - - - */ +#include - +#include "paper-def.hh" +#include "font-interface.hh" +#include "warn.hh" LY_DEFINE(ly_paper_get_font,"ly:paper-get-font", 2, 0, 0, (SCM paper, SCM chain), @@ -51,22 +41,63 @@ wild_compare (SCM field_val, SCM val) { return (val == SCM_BOOL_F || field_val == ly_symbol2scm ("*") || field_val == val); } +Font_metric* +get_font_by_design_size (Paper_def* paper, Real requested, + SCM font_vector) +{ + int n = SCM_VECTOR_LENGTH (font_vector); + Real size = 1e6; + Real last_size = -1e6; + int i = 0; + + for (; i < n; i++) + { + size = gh_scm2double (gh_car (SCM_VECTOR_REF (font_vector, i))); + if (size > requested) + break ; + last_size = size; + } + + if (i == n) + { + i = n-1; + } + else if (i > 0) + { + if ((requested / last_size) < (size / requested)) + { + i -- ; + size = last_size; + } + } + + return paper->find_font (gh_cdr (SCM_VECTOR_REF (font_vector, i)), + requested / size); +} + + +Font_metric* +get_font_by_mag_step (Paper_def* paper, Real requested_step, + SCM font_vector, Real default_size) +{ + return get_font_by_design_size (paper, + default_size * pow (2.0, requested_step / 6.0), + font_vector); +} + + /* We can probably get more efficiency points if we preprocess FONTS to make lookup easier. */ SCM -properties_to_font_name (SCM fonts, SCM alist_chain) +properties_to_font_size_family (SCM fonts, SCM alist_chain) { SCM shape = SCM_BOOL_F; SCM family = SCM_BOOL_F; SCM series = SCM_BOOL_F; - - SCM point_sz = ly_assoc_chain (ly_symbol2scm ("font-design-size"), alist_chain); - SCM rel_sz = SCM_BOOL_F; - shape = ly_assoc_chain (ly_symbol2scm ("font-shape"), alist_chain); family = ly_assoc_chain (ly_symbol2scm ("font-family"), alist_chain); series = ly_assoc_chain (ly_symbol2scm ("font-series"), alist_chain); @@ -79,40 +110,28 @@ properties_to_font_name (SCM fonts, SCM alist_chain) series = ly_cdr (series); - if (gh_pair_p (point_sz)) - point_sz = ly_cdr (point_sz); - else - { - rel_sz = ly_assoc_chain (ly_symbol2scm ("font-relative-size"), alist_chain); - if (gh_pair_p (rel_sz)) - rel_sz = ly_cdr (rel_sz); - } - for (SCM s = fonts ; gh_pair_p (s); s = ly_cdr (s)) { SCM qlist = ly_caar (s); - if (!wild_compare (scm_list_ref (qlist, gh_int2scm (1)), series)) + if (!wild_compare (SCM_VECTOR_REF (qlist, 0), series)) continue; - if (!wild_compare (scm_list_ref (qlist, gh_int2scm (2)), shape)) + if (!wild_compare (SCM_VECTOR_REF (qlist, 1), shape)) continue; - if (!wild_compare (scm_list_ref (qlist, gh_int2scm (3)), family)) + if (!wild_compare (SCM_VECTOR_REF (qlist, 2), family)) continue; - if (point_sz == SCM_BOOL_F && !wild_compare (ly_car (qlist), rel_sz)) - continue; - SCM qname = ly_cdar (s); return qname; } - warning (_ ("couldn't find any font satisfying ")); - scm_write (scm_list_n (point_sz, shape, series , family, rel_sz, + warning (_ ("couldn't find any font size family satisfying ")); + + scm_write (scm_list_n (shape, series , family, SCM_UNDEFINED), scm_current_error_port ()); scm_flush (scm_current_error_port ()); return scm_makfrom0str ("cmr10"); - } @@ -124,16 +143,38 @@ select_font (Paper_def *paper, SCM chain) if (!gh_pair_p (name) || !gh_string_p (gh_cdr (name))) { SCM fonts = paper->lookup_variable (ly_symbol2scm ("fonts")); - name = properties_to_font_name (fonts, chain); + name = properties_to_font_size_family (fonts, chain); } else name = gh_cdr (name); + + + if (gh_string_p (name)) + { + SCM mag = ly_assoc_chain (ly_symbol2scm ("font-magnification"), chain); - SCM mag = ly_assoc_chain (ly_symbol2scm ("font-magnification"), chain); - - Real rmag = gh_pair_p (mag) && gh_number_p (gh_cdr (mag)) - ? gh_scm2double (gh_cdr (mag)) : 1.0; + Real rmag = gh_pair_p (mag) && gh_number_p (gh_cdr (mag)) + ? gh_scm2double (gh_cdr (mag)) : 1.0; - Font_metric *fm = paper->find_font (name, rmag); - return fm; + return paper->find_font (name, rmag); + } + else if (gh_pair_p (name)) // (DEFAULT . FONT-VEC) pair + { + SCM vec = gh_cdr (name); + SCM base_size = gh_car (name); + + SCM font_size = ly_assoc_chain (ly_symbol2scm ("font-size"), chain); + Real req = 0.0; + if (gh_pair_p (font_size)) + req = gh_scm2double (ly_cdr (font_size)); + + return get_font_by_mag_step (paper, req, + vec, gh_scm2double (base_size)); + } + + assert (0); + + return 0; } + + diff --git a/lily/font-size-engraver.cc b/lily/font-size-engraver.cc index f04842e158..369f1ca5bc 100644 --- a/lily/font-size-engraver.cc +++ b/lily/font-size-engraver.cc @@ -1,5 +1,5 @@ /* - font-size-engraver.cc -- implement + font-size-engraver.cc -- implement Font_size_engraver source file of the GNU LilyPond music typesetter @@ -36,9 +36,9 @@ Font_size_engraver::acknowledge_grob (Grob_info gi) if (gh_number_p (sz) && gh_scm2double (sz) - && !gh_number_p (gi.grob_->get_grob_property ("font-relative-size"))) + && !gh_number_p (gi.grob_->get_grob_property ("font-size"))) { - gi.grob_->set_grob_property ("font-relative-size", sz); + gi.grob_->set_grob_property ("font-size", sz); } } diff --git a/lily/include/input-file-results.hh b/lily/include/input-file-results.hh index 95242400b9..22c4622f17 100644 --- a/lily/include/input-file-results.hh +++ b/lily/include/input-file-results.hh @@ -21,13 +21,13 @@ public: Sources sources_; Array inclusion_names_; Array target_strings_; - Link_array scores_; Protected_scm header_; - void do_deps (); - void do_scores (); + int score_count_; + + void do_deps (String); - Input_file_results (String file, String init); + Input_file_results (String init, String in, String out); ~Input_file_results (); private: @@ -37,7 +37,7 @@ private: extern Input_file_results* global_input_file; -void do_one_file (String init_string, String file_string); +void do_one_file (String init_string, String in_file, String out_file); #endif /* FILE_RESULTS_HH */ diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index 5af2ab0176..f0c82421f2 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -37,6 +37,7 @@ #include "drul-array.hh" + /* Guile 1.4.x compatibility */ #if GUILE_MINOR_VERSION < 5 @@ -80,6 +81,9 @@ inline SCM scm_c_make_vector (int k, SCM val) { #if GUILE_MINOR_VERSION < 7 #define scm_gc_unregister_collectable_memory(a,b,c) scm_done_free(b) #define scm_gc_register_collectable_memory(a,b,c) scm_done_malloc(b) +#define SCM_VECTOR_REF(v,i) (SCM_VELTS((v))[(i)]) + + #endif #include "direction.hh" @@ -220,8 +224,6 @@ unsigned int ly_scm_hash (SCM s); SCM index_get_cell (SCM cell, Direction d); SCM index_set_cell (SCM cell, Direction d, SCM val); - - SCM ly_snoc (SCM s, SCM list); SCM ly_split_list (SCM s, SCM list); SCM ly_unique (SCM list); @@ -233,8 +235,9 @@ SCM ly_unique (SCM list); */ void add_scm_init_func (void (*) ()); - +extern "C" { typedef SCM (*Scheme_function_unknown) (); +} #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96 typedef SCM (*Scheme_function_0) (); diff --git a/lily/include/midi-def.hh b/lily/include/midi-def.hh index 1434afab8a..c39510624f 100644 --- a/lily/include/midi-def.hh +++ b/lily/include/midi-def.hh @@ -29,8 +29,6 @@ public: int get_tempo (Moment moment); void set_tempo (Moment moment, int count_per_minute_i); - virtual int get_next_score_count () const; - static void reset_score_count (); }; #endif // MIDI_DEF_HH diff --git a/lily/include/music-output-def.hh b/lily/include/music-output-def.hh index cdfa93e939..c923fcab36 100644 --- a/lily/include/music-output-def.hh +++ b/lily/include/music-output-def.hh @@ -30,7 +30,6 @@ public: VIRTUAL_COPY_CONS (Music_output_def); Music_output_def (Music_output_def const&); Music_output_def (); - virtual int get_next_score_count () const; Global_translator *get_global_translator (); Translator_group *get_group_translator (String type) const; diff --git a/lily/include/music-output.hh b/lily/include/music-output.hh index ace7b0dae8..c77ae58069 100644 --- a/lily/include/music-output.hh +++ b/lily/include/music-output.hh @@ -21,15 +21,11 @@ class Music_output { public: Protected_scm header_; - String default_out_string_; - String origin_string_; - int errorlevel_; - virtual void process () {} + virtual void process (String) {} virtual ~Music_output (){} Music_output () { - errorlevel_ = 0; } }; diff --git a/lily/include/my-lily-lexer.hh b/lily/include/my-lily-lexer.hh index b548b4a23b..e50fd7273c 100644 --- a/lily/include/my-lily-lexer.hh +++ b/lily/include/my-lily-lexer.hh @@ -29,7 +29,7 @@ class My_lily_lexer : public Includable_lexer { Protected_scm scopes_; public: - String main_input_string_; + String main_input_name_; void * lexval; bool main_input_b_; diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh index 7f8534b5ba..730b95dde0 100644 --- a/lily/include/my-lily-parser.hh +++ b/lily/include/my-lily-parser.hh @@ -34,11 +34,12 @@ public: ~My_lily_parser (); void do_init_file (); - void parse_file ( String init_string, String file_string); + void parse_file (String init, String file, String out_name); public: Duration default_duration_; - + String output_basename_; + Scheme_hash_table *default_header_; int fatal_error_; diff --git a/lily/include/paper-def.hh b/lily/include/paper-def.hh index c177436ec8..ad898a679f 100644 --- a/lily/include/paper-def.hh +++ b/lily/include/paper-def.hh @@ -49,7 +49,7 @@ protected: VIRTUAL_COPY_CONS (Music_output_def); public: - Paper_outputter* get_paper_outputter () ; + Paper_outputter* get_paper_outputter (String) const; SCM font_descriptions ()const; virtual ~Paper_def (); @@ -66,8 +66,6 @@ public: Interval line_dimensions_int (int) const; - virtual int get_next_score_count () const; - static void reset_score_count (); void output_settings (Paper_outputter*) const; Font_metric * find_font (SCM name, Real mag); diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh index b7d500c8d6..6098856c58 100644 --- a/lily/include/paper-outputter.hh +++ b/lily/include/paper-outputter.hh @@ -27,8 +27,6 @@ class Paper_outputter { bool verbatim_scheme_b_; - - public: SCM output_func_ ; diff --git a/lily/include/paper-score.hh b/lily/include/paper-score.hh index 5310e2ac08..831f913e3e 100644 --- a/lily/include/paper-score.hh +++ b/lily/include/paper-score.hh @@ -42,7 +42,7 @@ public: protected: /* MAIN ROUTINES */ - virtual void process (); + virtual void process (String); private: /// before calc_breaking diff --git a/lily/include/performance.hh b/lily/include/performance.hh index 2976e11c58..a98133fc1e 100644 --- a/lily/include/performance.hh +++ b/lily/include/performance.hh @@ -27,7 +27,7 @@ public: void output_header_track (Midi_stream& midi_stream_r); void print () const; - void process (); + void process (String); Link_array audio_staffs_; Cons *audio_elem_p_list_; diff --git a/lily/include/score.hh b/lily/include/score.hh index 38e7d8b934..8a50481cc3 100644 --- a/lily/include/score.hh +++ b/lily/include/score.hh @@ -16,27 +16,22 @@ #include "parray.hh" #include "smobs.hh" -/// the total music def of one movement -class Score: public Input { +class Score : public Input +{ public: - /// paper_, staves_ and commands_ form the problem definition. Link_array defs_; SCM music_; SCM header_; - Input_file_results* input_file_; - - int errorlevel_; - /// construction Score (); Score (Score const&); - - - void process (); - void add_output (Music_output_def *def); DECLARE_SMOBS (Score,foo); private: - void run_translator (Music_output_def*); }; DECLARE_UNSMOB(Score,score); + + +SCM ly_run_translator (SCM, SCM); +SCM ly_render_output (SCM, SCM, SCM); +void default_rendering (SCM,SCM,SCM,SCM); #endif diff --git a/lily/input-file-results.cc b/lily/input-file-results.cc index f92671aa6c..ef55dee50c 100644 --- a/lily/input-file-results.cc +++ b/lily/input-file-results.cc @@ -32,6 +32,8 @@ #include "scm-hash.hh" #include "ly-modules.hh" +bool store_locations_global_b; + /* no ! suffix since it doesn't modify 1st argument. @@ -98,11 +100,11 @@ write_dependency_file (String fn, void -Input_file_results::do_deps () +Input_file_results::do_deps (String output) { if (dependency_global_b) { - Path p = split_path (output_name_global); + Path p = split_path (output); p.ext = "dep"; write_dependency_file (p.to_string (), target_strings_, @@ -110,37 +112,8 @@ Input_file_results::do_deps () } } - -void -Input_file_results::do_scores () -{ - if (header_ == SCM_EOL) - header_ = ly_make_anonymous_module (); - - for (int i=0; i < scores_.size (); i++) - { - Score* is = scores_[i]; - is->input_file_ = this; - - if (is->errorlevel_) - { - is->warning (_ ("Score contains errors; will not process it")); - exit_status_global |= 1; - } - else - { - is->process (); - } - } - do_deps (); -} - Input_file_results::~Input_file_results () { - for (int i=0; i < scores_.size (); i++) - scm_gc_unprotect_object (scores_[i]->self_scm ()); - scores_.clear (); - inclusion_names_.clear (); if (header_) header_ = SCM_EOL; @@ -154,43 +127,45 @@ Input_file_results::~Input_file_results () Input_file_results* global_input_file; -Input_file_results::Input_file_results (String init_string, String file_string) +Input_file_results::Input_file_results (String init, String in_file, String out_file) { - header_ = SCM_EOL; + header_ = ly_make_anonymous_module (); global_input_file = this; - + score_count_ = 0; sources_.set_path (&global_path); - My_lily_parser parser (this); - progress_indication (_f ("Now processing: `%s'", file_string.to_str0 ())); + progress_indication (_f ("Now processing: `%s'", in_file.to_str0 ())); progress_indication ("\n"); - parser.parse_file (init_string, file_string); + + My_lily_parser parser (this); + parser.parse_file (init, in_file, out_file); if (parser.error_level_) { exit_status_global = 1; } - else - do_scores (); + + do_deps (out_file); } void -do_one_file (String init_string, String file_string) +do_one_file (String init, String in_file, String out_file) { - if (init_string.length () && global_path.find (init_string).empty_b ()) + if (init.length () && global_path.find (init).empty_b ()) { - warning (_f ("can't find file: `%s'", init_string)); + warning (_f ("can't find file: `%s'", init)); warning (_f ("(search path: `%s')", global_path.to_string ().to_str0 ())); return; } - if ((file_string != "-") && global_path.find (file_string).empty_b ()) + + if ((in_file != "-") && global_path.find (in_file).empty_b ()) { - warning (_f ("can't find file: `%s'", file_string)); + warning (_f ("can't find file: `%s'", in_file)); return; } - Input_file_results inp_file(init_string, file_string); + Input_file_results inp_file (init, in_file, out_file); } diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index a91937a2ff..3c9fe9079b 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -13,7 +13,7 @@ #include #include /* isinf */ #include /* strdup, strchr */ - +#include #include "lily-proto.hh" diff --git a/lily/main.cc b/lily/main.cc index 6ea0664d18..44e2acf622 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -292,15 +292,6 @@ distill_inname (String str) return p; } -String -format_to_ext (String format) -{ - if (format == "tex") - /* .lytex change put off */ - return "tex"; // "lytex"; - return format; -} - void prepend_load_path (String dir) { @@ -353,15 +344,12 @@ main_prog (void *, int, char **) do { String infile (arg); - Midi_def::reset_score_count (); - Paper_def::reset_score_count (); - Path inpath = distill_inname (infile); /* By default, use base name of input file for output file name */ Path outpath = inpath; if (inpath.to_string () != "-") - outpath.ext = format_to_ext (output_format_global); + outpath.ext = output_format_global; /* By default, write output to cwd; do not copy directory part of input file name */ @@ -377,11 +365,7 @@ main_prog (void *, int, char **) else init = "init.ly"; - /* Burp: output name communication goes through _global */ - String save_output_name_global = output_name_global; - output_name_global = outpath.to_string (); - do_one_file (init, inpath.to_string ()); - output_name_global = save_output_name_global; + do_one_file (init, inpath.to_string (), outpath.to_string ()); p++; } while ((arg = oparser_p_static->get_next_arg ())); @@ -437,7 +421,8 @@ main (int argc, char **argv) String s = oparser_p_static->optional_argument_str0_; Path p = split_path (s); if (s != "-" && p.ext.empty_b ()) - p.ext = format_to_ext (output_format_global); + p.ext = output_format_global; + output_name_global = p.to_string (); } break; @@ -452,8 +437,11 @@ main (int argc, char **argv) case 'f': if (oparser_p_static->optional_argument_str0_ == "help") { - printf("See http://lilypond.org/wiki?OutputFormats for more information.\n"\ - "This option is for developers only.\n"); + printf("This option is for developers only; Read the source code for more information\n"); + + // actually it's not here, + // but we award you special points for looking here. + exit (0); } output_format_global = oparser_p_static->optional_argument_str0_; diff --git a/lily/mark-engraver.cc b/lily/mark-engraver.cc index 0d875ba8c1..003ec782f6 100644 --- a/lily/mark-engraver.cc +++ b/lily/mark-engraver.cc @@ -61,8 +61,9 @@ Mark_engraver::acknowledge_grob (Grob_info inf) if (text_ && Bar_line::has_interface (s)) { /* - Ugh. Figure out how to do this right at beginning of line, (without - creating class Bar_script : public Item). + TODO: make this configurable. RehearsalMark cannot be + break-aligned, since the width of the object should not be taken + into alignment considerations. */ text_->set_parent (s, X_AXIS); } diff --git a/lily/midi-def.cc b/lily/midi-def.cc index ec5428971a..e42f2dce6e 100644 --- a/lily/midi-def.cc +++ b/lily/midi-def.cc @@ -49,17 +49,3 @@ Midi_def::set_tempo (Moment one_beat_mom, int beats_per_minute_i) set_variable (ly_symbol2scm ("whole-in-seconds"), m.smobbed_copy ()); } - -int Midi_def::score_count_=0; - -int -Midi_def::get_next_score_count () const -{ - return score_count_++; -} - -void -Midi_def::reset_score_count () -{ - score_count_ = 0; -} diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc index 1f834889f4..bf03732119 100644 --- a/lily/music-output-def.cc +++ b/lily/music-output-def.cc @@ -19,12 +19,6 @@ #include "ly-smobs.icc" -int -Music_output_def::get_next_score_count () const -{ - return 0; -} - Music_output_def::Music_output_def () { scaled_fonts_ = SCM_EOL; @@ -36,6 +30,8 @@ Music_output_def::Music_output_def () scope_ = ly_make_anonymous_module(); } + + Music_output_def::~Music_output_def () { } @@ -118,24 +114,6 @@ Music_output_def::print_smob (SCM s, SCM p, scm_print_state *) return 1; } -/* - ugh: should move into Music_output_def (complication: .midi and .tex - need separate counts.) */ -String -Music_output_def::outname_string () -{ - String out = output_name_global; - int def = get_next_score_count (); - if (def && out != "-") - { - Path p = split_path (out); - p.base += "-" + to_string (def); - out = p.to_string (); - } - return out; -} - - SCM Music_output_def::get_scmvar (String s) const @@ -158,7 +136,6 @@ Music_output_def::lookup_variable (SCM sym) const return scm_variable_ref (var); } - LY_DEFINE(ly_paper_lookup, "ly:paper-lookup", 2, 0,0, diff --git a/lily/music.cc b/lily/music.cc index 7e6fe2b14f..e147eaa86f 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -215,8 +215,6 @@ Music::internal_set_mus_property (SCM s, SCM v) mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v); } - - #include "main.hh" void @@ -238,8 +236,8 @@ Music::~Music () } -LY_DEFINE(ly_get_music_length, - "ly:get-music-length", 1, 0, 0, (SCM mus), +LY_DEFINE(ly_music_length, + "ly:music-length", 1, 0, 0, (SCM mus), "Get the length (in musical time) of music expression @var{mus}.") { Music * sc = unsmob_music (mus); @@ -250,8 +248,7 @@ LY_DEFINE(ly_get_music_length, LY_DEFINE(ly_get_mus_property, "ly:get-mus-property", 2, 0, 0, (SCM mus, SCM sym), "Get the property @var{sym} of music expression @var{mus}.\n" - "If @var{sym} is undefined, return @code{'()}.\n" - ) + "If @var{sym} is undefined, return @code{'()}.\n" ) { Music * sc = unsmob_music (mus); SCM_ASSERT_TYPE(sc, mus, SCM_ARG1, __FUNCTION__, "music"); @@ -395,3 +392,4 @@ make_music_by_name (SCM sym) scm_gc_protect_object (rv); return unsmob_music (rv); } + diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index bd57eb0899..07ab9374a6 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -161,12 +161,12 @@ My_lily_lexer::lookup_identifier (String s) void My_lily_lexer::start_main_input () { - new_input (main_input_string_, &global_input_file->sources_); + new_input (main_input_name_, &global_input_file->sources_); allow_includes_b_ = allow_includes_b_ && ! (safe_global_b); scm_module_define (gh_car (scopes_), ly_symbol2scm ("input-file-name"), - scm_makfrom0str (main_input_string_.to_str0())); + scm_makfrom0str (main_input_name_.to_str0())); } void diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index b912dc4b51..86d7bc3fa9 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -35,11 +35,12 @@ My_lily_parser::~My_lily_parser () void -My_lily_parser::parse_file (String init, String s) +My_lily_parser::parse_file (String init, String in_file, String out_file) { lexer_ = new My_lily_lexer; - - lexer_->main_input_string_ = s; + output_basename_ = out_file; + + lexer_->main_input_name_ = in_file; progress_indication (_ ("Parsing...")); diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 4d59d1f763..a784bfab15 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -67,25 +67,11 @@ Paper_def::line_dimensions_int (int n) const } -int Paper_def::score_count_ = 0; - -int -Paper_def::get_next_score_count () const -{ - return score_count_ ++; -} - -void -Paper_def::reset_score_count () -{ - score_count_ = 0; -} Paper_outputter* -Paper_def::get_paper_outputter () +Paper_def::get_paper_outputter (String outname) const { - String outname = outname_string (); progress_indication (_f ("paper output to `%s'...", outname == "-" ? String ("") : outname)); diff --git a/lily/paper-score.cc b/lily/paper-score.cc index d6af7039ca..5feda5abf9 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -72,7 +72,7 @@ Paper_score::calc_breaking () urg. clean me */ void -Paper_score::process () +Paper_score::process (String outname) { if (verbose_global_b) progress_indication (_f ("Element count %d (spanners %d) ", @@ -95,7 +95,7 @@ Paper_score::process () Array breaking = calc_breaking (); system_->break_into_pieces (breaking); - outputter_ = paper_->get_paper_outputter (); + outputter_ = paper_->get_paper_outputter (outname); outputter_->output_header (); outputter_->output_version (); @@ -112,10 +112,13 @@ Paper_score::process () outputter_->output_scope (header_, "lilypond"); outputter_->write_header_fields_to_file (header_); } - + +#if 0 + // todo: transport origin_string_ in header. outputter_->output_comment (_ ("Outputting Score, defined at: ")); outputter_->output_comment (origin_string_); - +#endif + outputter_->output_scope (paper_->scope_, "lilypondpaper"); SCM scm = scm_list_n (ly_symbol2scm ("header-end"), SCM_UNDEFINED); diff --git a/lily/parser.yy b/lily/parser.yy index ee022a6185..640eb38819 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -53,7 +53,6 @@ TODO: */ #include -#include #include #include @@ -83,7 +82,6 @@ TODO: #include "text-item.hh" #include "music-list.hh" - #define MY_MAKE_MUSIC(x) make_music_by_name (ly_symbol2scm (x)) @@ -429,7 +427,36 @@ toplevel_expression: THIS->input_file_->header_ = $1; } | score_block { - THIS->input_file_->scores_.push ($1); + Score * sc = $1; + + SCM head = ly_module_p (sc->header_) ? sc->header_ : THIS->input_file_->header_.to_SCM (); + + Path p = split_path (THIS->output_basename_); + int *c = &THIS->input_file_->score_count_; + if (*c) + { + p.base += "-" + to_string (*c); + } + + (*c)++; + SCM outname = scm_makfrom0str (p.to_string ().to_str0()); + + for (int i=0; i < sc->defs_.size (); i++) + default_rendering (sc->music_, sc->defs_[i]->self_scm(),head, outname); + + if (sc->defs_.empty ()) + { + Music_output_def *id = + unsmob_music_output_def (THIS->lexer_->lookup_identifier + ("$defaultpaper")); + + id = id ? id->clone () : new Paper_def; + + default_rendering (sc->music_, id->self_scm(), head, outname); + + scm_gc_unprotect_object (id->self_scm ()); + } + scm_gc_unprotect_object (sc->self_scm()); } | output_def { if (dynamic_cast ($1)) @@ -559,15 +586,16 @@ translator_spec_block: ; translator_spec_body: - TRANSLATOR_IDENTIFIER { + /**/ { + $$ = Translator_def::make_scm (); + unsmob_translator_def ($$)->set_spot (THIS->here_input ()); + } + | TRANSLATOR_IDENTIFIER { $$ = $1; unsmob_translator_def ($$)-> set_spot (THIS->here_input ()); } - | TYPE STRING { - $$ = Translator_def::make_scm (); - Translator_def*td = unsmob_translator_def ($$); - td->translator_group_type_ = $2; - td->set_spot (THIS->here_input ()); + | translator_spec_body TYPE STRING { + unsmob_translator_def ($$)->translator_group_type_ = $3; } | translator_spec_body DESCRIPTION string { unsmob_translator_def ($$)->description_ = $3; @@ -627,12 +655,7 @@ score_block: /*cont*/ '{' score_body '}' { THIS->pop_spot (); $$ = $4; - if (!$$->defs_.size ()) - { - Music_output_def *id = - unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper")); - $$->add_output (id ? id->clone () : new Paper_def ); - } + } ; @@ -661,7 +684,7 @@ score_body: $$->header_ = $2; } | score_body output_def { - $$->add_output ($2); + $$->defs_.push ($2); } | score_body error { diff --git a/lily/performance.cc b/lily/performance.cc index 23be820ad0..740465d290 100644 --- a/lily/performance.cc +++ b/lily/performance.cc @@ -110,8 +110,9 @@ Performance::output_header_track (Midi_stream& midi_stream) Midi_text at (&at_a); midi_track.add (Moment (0), &at); - - str = _f ("from musical definition: %s", origin_string_); + + // TODO: + // str = _f ("from musical definition: %s", origin_string_); Audio_text from_a (Audio_text::TEXT, str); Midi_text from (&from_a); @@ -147,19 +148,11 @@ Performance::add_element (Audio_element *p) void -Performance::process () +Performance::process (String out) { - String out = output_name_global; if (out == "-") out = "lelie.midi"; - int def = midi_->get_next_score_count (); - if (def) - { - Path p = split_path (out); - p.base += "-" + to_string (def); - out = p.to_string (); - } - + /* Maybe a bit crude, but we had this before */ Path p = split_path (out); p.ext = "midi"; diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 67a877306e..cb993f4bab 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -144,7 +144,6 @@ Piano_pedal_engraver::acknowledge_grob (Grob_info info) if (p->line_spanner_) { Side_position_interface::add_support (p->line_spanner_, info.grob_); - add_bound_item (p->line_spanner_,info.grob_); } if (p->bracket_) @@ -404,10 +403,22 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, bool mixed) p->bracket_->set_grob_property ("pedal-text", p->item_->self_scm ()); } - p->bracket_->set_bound (LEFT, unsmob_grob (get_property ("currentMusicalColumn"))); - Axis_group_interface::add_element (p->line_spanner_, p->bracket_); - add_bound_item (p->line_spanner_, p->bracket_->get_bound (LEFT)); + /* + We do not use currentMusicalColumn for the left span-point. + If the column as accidentals (eg on a different stave), the + currentMusicalColumn is too wide, making the bracket too big. + + TODO: + + Hmm. What do we do when there are no notes when the spanner starts? + + TODO: + + what about the right span point? + + */ + Axis_group_interface::add_element (p->line_spanner_, p->bracket_); announce_grob (p->bracket_, p->event_drul_[START]->self_scm ()); if (!p->event_drul_[STOP]) diff --git a/lily/recording-group-engraver.cc b/lily/recording-group-engraver.cc new file mode 100644 index 0000000000..615992d548 --- /dev/null +++ b/lily/recording-group-engraver.cc @@ -0,0 +1,91 @@ +/* + recording-group-engraver.cc -- implement Recording_group_engraver + + source file of the GNU LilyPond music typesetter + + (c) 2003 Han-Wen Nienhuys + + */ + +#include "engraver-group-engraver.hh" +#include "protected-scm.hh" + +class Recording_group_engraver : public Engraver_group_engraver +{ +public: + TRANSLATOR_DECLARATIONS(Recording_group_engraver); + virtual bool try_music (Music *m); + virtual void start_translation_timestep (); + virtual void stop_translation_timestep (); + virtual void finalize (); + virtual void initialize (); + Protected_scm accumulator_; +}; + +void +Recording_group_engraver::initialize () +{ + Engraver_group_engraver::initialize (); + accumulator_ = gh_cons (SCM_EOL, SCM_EOL); +} + +Recording_group_engraver::Recording_group_engraver() +{ +} + +void +Recording_group_engraver::start_translation_timestep () +{ + Engraver_group_engraver::start_translation_timestep(); + + scm_set_car_x (accumulator_, gh_cons (now_mom ().smobbed_copy (), SCM_EOL)); +} + +void +Recording_group_engraver::stop_translation_timestep () +{ + Engraver_group_engraver::stop_translation_timestep(); + scm_set_cdr_x (accumulator_, gh_cons (gh_car (accumulator_), gh_cdr (accumulator_))); + + scm_set_car_x (accumulator_, SCM_EOL); +} + +void +Recording_group_engraver::finalize () +{ + Engraver_group_engraver::finalize (); + SCM proc = get_property ("recordEventSequence"); + + if (gh_procedure_p (proc)) + scm_call_2 (proc, daddy_trans_->self_scm(), gh_cdr (accumulator_)); + + accumulator_ = SCM_EOL; +} + +bool +Recording_group_engraver::try_music (Music *m) +{ + bool here_success = Translator_group::try_music_on_nongroup_children (m); + bool retval = here_success; + if (!here_success && daddy_trans_) + retval = daddy_trans_->try_music (m); + + SCM seq = gh_cdar (accumulator_); + seq = gh_cons (gh_cons (m->self_scm(), gh_bool2scm (here_success)), + seq); + + scm_set_cdr_x (gh_car (accumulator_), seq); + + return retval; +} + + +ENTER_DESCRIPTION(Recording_group_engraver, + "Engraver_group_engraver that records all music events " + "for this context. Calls the procedure " + "in @code{recordEventSequence} when finished.", + "", + "", + "", + "recordEventSequence", + ""); diff --git a/lily/scm-option.cc b/lily/scm-option.cc index 39f3094356..de3deb0005 100644 --- a/lily/scm-option.cc +++ b/lily/scm-option.cc @@ -98,7 +98,7 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val), "@end table\n" "\n" "This function is useful to call from the command line: @code{lilypond -e\n" -"\"(ly-set-option 'midi-debug #t_)\"}.\n") +"\"(ly-set-option 'midi-debug #t)\"}.\n") { if (val == SCM_UNDEFINED) val = SCM_BOOL_T; diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index d19bf5dd91..d7e740850f 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -84,7 +84,7 @@ Score_engraver::finish () progress_indication ("[" + to_string (breaks_) + "]"); check_removal (); - removal_processing (); + finalize (); } diff --git a/lily/score-performer.cc b/lily/score-performer.cc index ee48102cbb..0cb5d00a8b 100644 --- a/lily/score-performer.cc +++ b/lily/score-performer.cc @@ -98,7 +98,7 @@ void Score_performer::finish () { check_removal (); - removal_processing (); + finalize (); } Music_output * diff --git a/lily/score.cc b/lily/score.cc index 04e09684e3..7da39afce4 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -31,19 +31,51 @@ Score::Score () : Input () { - input_file_ = 0; header_ = SCM_EOL; music_ = SCM_EOL; - errorlevel_ = 0; smobify_self (); } +Score::~Score () +{ + +} + + + + +IMPLEMENT_SMOBS (Score); +IMPLEMENT_DEFAULT_EQUAL_P (Score); + + +SCM +Score::mark_smob (SCM s) +{ + Score * sc = (Score*) SCM_CELL_WORD_1 (s); + + if (sc->header_) + scm_gc_mark (sc->header_); + for (int i = sc->defs_.size (); i--;) + scm_gc_mark (sc->defs_[i]->self_scm ()); + + return sc->music_; +} + +int +Score::print_smob (SCM , SCM p, scm_print_state*) +{ + scm_puts ("#", p); + + return 1; +} + + + /* store point & click locations. Global to save some time. (Sue us!) */ -bool store_locations_global_b; Score::Score (Score const &s) : Input (s) @@ -58,32 +90,35 @@ Score::Score (Score const &s) for (int i=0; i < s.defs_.size (); i++) defs_.push (s.defs_[i]->clone ()); - errorlevel_ = s.errorlevel_; header_ = ly_make_anonymous_module (); if (ly_module_p (s.header_)) ly_copy_module_variables (header_, s.header_); } -Score::~Score () -{ - -} - -void -Score::run_translator (Music_output_def *odef) +LY_DEFINE(ly_run_translator, "ly:run-translator", + 2, 0, 0, + (SCM mus, SCM output_def), + "Process @var{mus} according to @var{output_def}. A interpretation " +"context is set up, and @var{mus} is interpreted with it. The " +"context is returned in its final state." ) { + Music_output_def *odef = unsmob_music_output_def (output_def); + Music * music = unsmob_music (mus); + + SCM_ASSERT_TYPE (music, mus, SCM_ARG1, __FUNCTION__, "Music"); + SCM_ASSERT_TYPE (odef, output_def, SCM_ARG2, __FUNCTION__, "Output definition"); + Cpu_timer timer; Global_translator * trans = odef->get_global_translator (); if (!trans) { programming_error ("no toplevel translator"); - return ; + return SCM_BOOL_F; } progress_indication (_ ("Interpreting music...")); - Music * music = unsmob_music (music_); trans->final_mom_ = music->get_length (); SCM protected_iter = Music_iterator::get_static_get_iterator (music); @@ -95,8 +130,7 @@ Score::run_translator (Music_output_def *odef) if (! iter->ok ()) { warning (_ ("Need music in a score")); - errorlevel_ =1; - return ; + return SCM_BOOL_F; // todo: shoudl throw exception. } trans->start (); @@ -105,73 +139,48 @@ Score::run_translator (Music_output_def *odef) scm_remember_upto_here_1 (protected_iter); trans->finish (); - if (errorlevel_) - { - // should we? hampers debugging. - warning (_ ("errors found.")); - } - - Music_output * output = trans->get_output (); - scm_gc_unprotect_object (trans->self_scm ()); - if (verbose_global_b) progress_indication (_f ("elapsed time: %.2f seconds", timer.read ())); - if (!header_) - header_ = ly_make_anonymous_module(); // ug.h - - output->header_ = header_; - output->origin_string_ = location_string (); - - progress_indication ("\n"); - output->process (); - delete output ; + return scm_gc_unprotect_object (trans->self_scm ()); } -void -Score::process () -{ - if (!unsmob_music (music_)) - return; - for (int i=0; i < defs_.size (); i++) - { - if (no_paper_global_b - && dynamic_cast (defs_[i])) - continue; - run_translator (defs_[i]); - } -} - - -void -Score::add_output (Music_output_def *pap) +LY_DEFINE(ly_render_output, "ly:render-output", + 3,0,0, + (SCM context, SCM header, SCM out_filename), + "Given a Score context in its final state, calculate the output, " + "and dump the result to @var{out-filename}, using " + "@var{header} for the bibliographic information.") { - defs_.push (pap); -} - -IMPLEMENT_SMOBS (Score); -IMPLEMENT_DEFAULT_EQUAL_P (Score); - + Translator *tr = unsmob_translator (context); + Global_translator * gt = dynamic_cast (tr); + + SCM_ASSERT_TYPE(gt, context, SCM_ARG1, __FUNCTION__, + "Score context"); + SCM_ASSERT_TYPE(ly_module_p(header), header, SCM_ARG2, __FUNCTION__, + "module"); + SCM_ASSERT_TYPE(gh_string_p (out_filename), out_filename, SCM_ARG3, __FUNCTION__, + "output filename"); -SCM -Score::mark_smob (SCM s) -{ - Score * sc = (Score*) SCM_CELL_WORD_1 (s); + Music_output * output = gt->get_output (); - if (sc->header_) - scm_gc_mark (sc->header_); - for (int i = sc->defs_.size (); i--;) - scm_gc_mark (sc->defs_[i]->self_scm ()); + output->header_ = header; - return sc->music_; + progress_indication ("\n"); + output->process (ly_scm2string (out_filename)); + + delete output ; + + return SCM_UNDEFINED ; } -int -Score::print_smob (SCM , SCM p, scm_print_state*) +void +default_rendering (SCM mus, SCM outdef, SCM head, SCM outname) { - scm_puts ("#", p); - - return 1; + SCM context = ly_run_translator (mus, outdef); + + if (unsmob_translator (context)) + ly_render_output (context, head, outname); } diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index 4e733fe639..5d0213b07c 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -361,7 +361,7 @@ Spacing_spanner::set_springs (SCM smob) { Grob *me = unsmob_grob (smob); - Link_array all (me->pscore_->system_->columns ()) ; + Link_array all (me->pscore_->system_->columns ()); set_explicit_neighbor_columns (all); diff --git a/lily/stem.cc b/lily/stem.cc index eaedf13ec8..e14fc302be 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -479,16 +479,21 @@ Stem::position_noteheads (Grob*me) Real l = Note_head::head_extent (heads[i], X_AXIS).length (); Direction d = get_direction (me); - /* reversed head should be shifted l-thickness, but this looks - too crowded, so we only shift l-0.5*thickness. - Notice that this leads to assymetry: Normal heads overlap - the stem 100% whereas reversed heads only overlaps the stem - 50% */ - #define magic 0.5 - heads[i]->translate_axis ((l-thick*magic) * d, X_AXIS); + /* + Reversed head should be shifted l-thickness, but this + looks too crowded, so we only shift l-0.5*thickness. + + This leads to assymetry: Normal heads overlap the + stem 100% whereas reversed heads only overlaps the + stem 50% + + */ + + Real reverse_overlap =0.5; + heads[i]->translate_axis ((l-thick*reverse_overlap) * d, X_AXIS); if (invisible_b(me)) - heads[i]->translate_axis (-thick*(2-magic) * d , X_AXIS); + heads[i]->translate_axis (-thick*(2 - reverse_overlap) * d , X_AXIS); /* TODO: diff --git a/lily/string-number-engraver.cc b/lily/string-number-engraver.cc index 350530053d..ba527cc8fe 100644 --- a/lily/string-number-engraver.cc +++ b/lily/string-number-engraver.cc @@ -16,7 +16,7 @@ protected: bool -String_number_engraver::try_music (Music * m) +String_number_engraver::try_music (Music * ) { return true; } diff --git a/lily/text-spanner.cc b/lily/text-spanner.cc index ce660216ff..6de80dd798 100644 --- a/lily/text-spanner.cc +++ b/lily/text-spanner.cc @@ -72,7 +72,6 @@ Text_spanner::brew_molecule (SCM smob) while (flip (&d) != LEFT); - SCM properties = Font_interface::font_alist_chain (me); SCM edge_text = me->get_grob_property ("edge-text"); Drul_array edge; diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 7cc71e4d51..681c1dfaad 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -17,6 +17,7 @@ #include "grob-pitch-tuple.hh" #include "warn.hh" #include "note-head.hh" +#include "staff-symbol-referencer.hh" /** Manufacture ties. Acknowledge noteheads, and put them into a @@ -89,8 +90,9 @@ Tie_engraver::acknowledge_grob (Grob_info i) for (int i = heads_to_tie_.size (); i--;) { Grob *th = heads_to_tie_[i]; - int staff_pos = gh_scm2int (h->get_grob_property ("staff-position")); - int left_staff_pos = gh_scm2int (th->get_grob_property ("staff-position")); + int staff_pos = int (Staff_symbol_referencer::get_position (h)); + int left_staff_pos = int (Staff_symbol_referencer::get_position (th)); + if (staff_pos == left_staff_pos) { Grob * p = new Spanner (get_property ("Tie")); diff --git a/lily/translator-group.cc b/lily/translator-group.cc index 655d15f4f5..f34b0c2e76 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -168,6 +168,7 @@ Translator_group::try_music (Music* m) if (!hebbes_b && daddy_trans_) hebbes_b = daddy_trans_->try_music (m); + return hebbes_b ; } @@ -189,7 +190,7 @@ Translator_group::get_ancestor (int level) void Translator_group::terminate_translator (Translator*r) { - r->removal_processing (); + r->finalize (); /* Return value ignored. GC does the rest. */ @@ -395,7 +396,7 @@ Translator_group::initialize () void Translator_group::finalize () { - each (&Translator::removal_processing); + each (&Translator::finalize); } diff --git a/lily/translator.cc b/lily/translator.cc index 3e440ab335..5d4af073f5 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -72,12 +72,6 @@ Translator::now_mom () const return daddy_trans_->now_mom (); } -void -Translator::removal_processing () -{ - finalize (); -} - void Translator::do_announces () { diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 5684d564d4..01f27a16d2 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -536,9 +536,9 @@ ScoreContext = \translator { (Voice Stem lengths ,(map (lambda (x) (* 0.8 x)) '(3.5 3.5 3.5 4.5 5.0))) (Voice Stem stem-shorten (0.4 0)) - (Voice Stem font-relative-size -1) - (Voice NoteHead font-relative-size -1) - (Voice Dots font-relative-size -1) + (Voice Stem font-size -3) + (Voice NoteHead font-size -3) + (Voice Dots font-size -3) (Voice Stem beamed-lengths ,(map (lambda (x) (* 0.8 x)) '(3.26))) (Voice Stem beamed-minimum-free-lengths @@ -554,7 +554,7 @@ ScoreContext = \translator { (Voice Beam position-callbacks (,Beam::least_squares ,Beam::check_concave ,Beam::slope_damping)) - (Staff Accidental font-relative-size -2) + (Staff Accidental font-size -4) (Voice Slur direction -1) ) diff --git a/ly/gregorian-init.ly b/ly/gregorian-init.ly index f1e8c08dd0..76c943b1f7 100644 --- a/ly/gregorian-init.ly +++ b/ly/gregorian-init.ly @@ -1,4 +1,4 @@ -\version "1.9.8" +\version "2.1.1" %%%%%%%% %%%%%%%% shortcuts common for all styles of gregorian chant notation @@ -39,7 +39,7 @@ cavum = % virgula = { \once \property Voice.BreathingSign \override #'text = #(make-musicglyph-markup "scripts-rcomma") - \once \property Voice.BreathingSign \override #'font-relative-size = #-1 + \once \property Voice.BreathingSign \override #'font-size = #-2 % Workaround: add padding. Correct fix would be spacing engine handle this. \once \property Voice.BreathingSign \override #'extra-X-extent = #'(-1.0 . 0) @@ -48,7 +48,7 @@ virgula = { } caesura = { \once \property Voice.BreathingSign \override #'text = #(make-musicglyph-markup "scripts-rvarcomma") - \once \property Voice.BreathingSign \override #'font-relative-size = #-1 + \once \property Voice.BreathingSign \override #'font-size = #-2 % Workaround: add padding. Correct fix would be spacing engine handle this. \once \property Voice.BreathingSign \override #'extra-X-extent = #'(-1.0 . 0) diff --git a/ly/paper11-init.ly b/ly/paper11-init.ly index cf373e578b..300ae89c50 100644 --- a/ly/paper11-init.ly +++ b/ly/paper11-init.ly @@ -4,7 +4,7 @@ paperEleven = \paper { staffheight = 11.0\pt - #(define fonts (make-font-list 'paper11)) + #(define fonts (scale-font-list (/ 11. 20.))) \include "params-init.ly" } diff --git a/ly/paper13-init.ly b/ly/paper13-init.ly index 98fcf5e800..544161575f 100644 --- a/ly/paper13-init.ly +++ b/ly/paper13-init.ly @@ -5,7 +5,7 @@ paperThirteen = \paper { staffheight = 13.0\pt - #(define fonts (make-font-list 'paper13)) + #(define fonts (scale-font-list (/ 13. 20.))) \include "params-init.ly" } diff --git a/ly/paper16-init.ly b/ly/paper16-init.ly index 983d71763e..8ace29880a 100644 --- a/ly/paper16-init.ly +++ b/ly/paper16-init.ly @@ -5,7 +5,7 @@ paperSixteen = \paper { staffheight = 16.0\pt - #(define fonts (make-font-list 'paper16)) + #(define fonts (scale-font-list (/ 16. 20.))) \include "params-init.ly" } diff --git a/ly/paper20-init.ly b/ly/paper20-init.ly index c981c38dfd..616c2c404d 100644 --- a/ly/paper20-init.ly +++ b/ly/paper20-init.ly @@ -5,9 +5,21 @@ paperTwenty = \paper { staffheight = 20.0\pt - #(define fonts (make-font-list 'paper20)) + #(define fonts (scale-font-list 1.0)) \include "params-init.ly" } \paper { \paperTwenty } + + +%{ + +; note: +; you can add fonts manually in the paper block by issuing + +#(set! fonts (append ...myfonts... fonts)) + +for the format of myfonts, see font.scm + +%} diff --git a/ly/paper23-init.ly b/ly/paper23-init.ly index 35affc4d44..e555314076 100644 --- a/ly/paper23-init.ly +++ b/ly/paper23-init.ly @@ -5,7 +5,7 @@ paperTwentythree = \paper { staffheight = 23.0\pt - #(define fonts (make-font-list 'paper23)) + #(define fonts (scale-font-list (/ 23. 20.))) \include "params-init.ly" } diff --git a/ly/paper26-init.ly b/ly/paper26-init.ly index f4d3252187..acf8499dcd 100644 --- a/ly/paper26-init.ly +++ b/ly/paper26-init.ly @@ -4,7 +4,7 @@ paperTwentysix = \paper { staffheight = 26.0\pt - #(define fonts (make-font-list 'paper26)) + #(define fonts (scale-font-list (/ 26. 20.))) \include "params-init.ly" } diff --git a/ly/params-init.ly b/ly/params-init.ly index 23990bdb5c..1091b75b09 100644 --- a/ly/params-init.ly +++ b/ly/params-init.ly @@ -1,4 +1,4 @@ -\version "1.9.8" +\version "2.1.1" % JUNKME. %% deprecated @@ -60,7 +60,6 @@ interscoreline = 4. \mm %% #(define font-defaults '((font-family . music) - (font-relative-size . 0) (font-shape . upright) (baseline-skip . 2) (word-space . 0.6) diff --git a/mf/GNUmakefile b/mf/GNUmakefile index c8b1161194..393495a7c0 100644 --- a/mf/GNUmakefile +++ b/mf/GNUmakefile @@ -51,9 +51,7 @@ INSTALLATION_OUT_DIR3=$(local_lilypond_datadir)/fonts/tfm INSTALLATION_OUT_FILES3=$(TFM_FILES) -SAUTER_FONTS = cmbxti5 cmbxti6 cmbxti7 cmbxti8 cmbxti12 \ - cmcsc7 cmcsc8 cmcsc12 cmtt5 cmtt6 cmtt7 cmtt17 \ - cmbx14 cmbx17 cmti5 cmti6 cmss5 cmss6 cmss7 cmss14 +SAUTER_FONTS = cmbxti7 ALL_FONTS = $(FETA_FONTS) $(SAUTER_FONTS) diff --git a/mf/feta-bolletjes.mf b/mf/feta-bolletjes.mf index 1d6e27ce44..396f895dca 100644 --- a/mf/feta-bolletjes.mf +++ b/mf/feta-bolletjes.mf @@ -49,12 +49,22 @@ def notehead_calc = enddef; +% a: x diameter +% b: y diameter +% err_x: drift of y axis at top +% err_y: drift of x axis at right +def distorted_ellipse(expr a,b,err_y,err_x,super) = + superellipse((a,err_x),(-err_y,b),(-a,-err_x),(err_y,-b),super); + enddef; + + + % draw the outer and inner ellipse. def notehead_draw = path black,white; black=distorted_ellipse(a,beta,a*err_y_a,0,superness); white=distorted_ellipse(ai,bi,ai*err_y_ai,bi*err_x_bi,inner_superness); -if test>1: %fixme +if test > 1: %fixme save x; x1=-x3=a; x2=x4=0; y1=y3=0; y2=-y4=b; penlabels(1,2,3,4); @@ -145,12 +155,14 @@ fet_endchar; fet_beginchar("Half notehead", "1", "halfhead") setup_notehead_vars; - % a_b:=1.49; % after text + % a_b:=1.49; % after text a_b:=1.50; % after drawing err_y_a:=0.157; tilt:=34; + % superness:=0.66; superness:=0.67; % jcn + % ai_a:=0.863; % was 0.85 % set to 0.83 to avoid stem entering white part. diff --git a/mf/feta-din-code.mf b/mf/feta-din-code.mf index 0523d2189a..9919a89616 100644 --- a/mf/feta-din-code.mf +++ b/mf/feta-din-code.mf @@ -1,4 +1,11 @@ +%% +% +% TODO: blot diameter should be fixed, not scalable. +% +% + + save serif_thick; serif_thick# = 1.1 stafflinethickness#; define_blacker_pixels (serif_thick); diff --git a/mf/feta-generic.mf b/mf/feta-generic.mf index 0249176f87..4c1e0916eb 100644 --- a/mf/feta-generic.mf +++ b/mf/feta-generic.mf @@ -39,15 +39,6 @@ if test = 0: input feta-solfa; else: - input feta-bolletjes; - input feta-banier; -% input feta-eindelijk; -% input feta-klef; -% input feta-toevallig; -% input feta-schrift; -% input feta-haak; -% input feta-timesig; -% input feta-pendaal; -% input feta-accordion; -% input feta-solfa; + input feta-test-generic.mf; + fi diff --git a/mf/feta-macros.mf b/mf/feta-macros.mf index a39c3a1fd7..ae413e6a51 100644 --- a/mf/feta-macros.mf +++ b/mf/feta-macros.mf @@ -118,16 +118,6 @@ def simple_serif(expr p,q, a)= enddef; % -% a: x diameter -% b: y diameter -% err_x: drift of y axis at top -% err_y: drift of x axis at right -def distorted_ellipse(expr a,b,err_y,err_x,super) = - superellipse((a,err_x),(-err_y,b),(-a,-err_x),(err_y,-b),super); - enddef; - - - % % draw an axis aligned block making sure that edges are on pixels. % diff --git a/mf/feta-params.mf b/mf/feta-params.mf index d57d5c3721..e822bcc591 100644 --- a/mf/feta-params.mf +++ b/mf/feta-params.mf @@ -6,6 +6,7 @@ stafflines = 5; staff_space#:=staffsize#/(stafflines-1); + % URG! %font_x_height staff_space# ; diff --git a/mf/feta-toevallig.mf b/mf/feta-toevallig.mf index c6812f4f05..1c5ca0165e 100644 --- a/mf/feta-toevallig.mf +++ b/mf/feta-toevallig.mf @@ -357,7 +357,7 @@ fet_beginchar("Double Sharp", "4", "sharpsharp") z5 = z1 reflectedabout((0,0), (1,1)); labels(1,2,3,4,5); - pickup pencircle scaled 1/20 staff_space; + pickup pencircle scaled blot_diameter; filldraw z1{dir 45} .. {right}z2 -- z3 -- z4{down} .. {dir 225}z5 .. cycle; diff --git a/mf/feta11.mf b/mf/feta11.mf index 95785f3595..c0e87d7d8c 100644 --- a/mf/feta11.mf +++ b/mf/feta11.mf @@ -4,7 +4,7 @@ input feta-autometric; fet_beginfont("feta", 11); -staffsize#:=11pt#; +staffsize#:=11.22pt#; test:=0; diff --git a/mf/feta13.mf b/mf/feta13.mf index 161d9d9fb6..1987d39750 100644 --- a/mf/feta13.mf +++ b/mf/feta13.mf @@ -1,10 +1,9 @@ % feta16.mf % part of LilyPond's pretty-but-neat music font - input feta-autometric; fet_beginfont("feta", 13); -staffsize#:=13pt#; +staffsize#:=12.60pt#; test:=0; diff --git a/mf/feta16.mf b/mf/feta16.mf index 8d7d9538ab..30d7b0a2a2 100644 --- a/mf/feta16.mf +++ b/mf/feta16.mf @@ -3,7 +3,7 @@ input feta-autometric; fet_beginfont("feta", 16); -staffsize#:=16pt#; +staffsize#:=15.87pt#; test:=0; diff --git a/mf/feta23.mf b/mf/feta23.mf index 5ef48a8a0d..95962446ba 100644 --- a/mf/feta23.mf +++ b/mf/feta23.mf @@ -2,9 +2,10 @@ % part of LilyPond's pretty-but-neat music font input feta-autometric; -% why is this 22.5? + +% todo change file name fet_beginfont("feta", 22.5); -staffsize#:=22.5pt#; +staffsize#:=22.45pt#; test:=0; diff --git a/mf/feta26.mf b/mf/feta26.mf index add32d85f9..ec85398e99 100644 --- a/mf/feta26.mf +++ b/mf/feta26.mf @@ -3,7 +3,7 @@ input feta-autometric; fet_beginfont("feta", 26); -staffsize#:=26pt#; +staffsize#:=25.20pt#; test:=0; diff --git a/mf/parmesan11.mf b/mf/parmesan11.mf index 53804759ad..d0877b022d 100644 --- a/mf/parmesan11.mf +++ b/mf/parmesan11.mf @@ -1,7 +1,7 @@ % parmesan11.mf % part of LilyPond's pretty-but-neat music font -staffsize#:=11pt#; +staffsize#:=11.22pt#; input feta-autometric; fet_beginfont("parmesan", 11); diff --git a/mf/parmesan13.mf b/mf/parmesan13.mf index 765744646e..06878f2388 100644 --- a/mf/parmesan13.mf +++ b/mf/parmesan13.mf @@ -1,7 +1,7 @@ % parmesan13.mf % part of LilyPond's pretty-but-neat music font -staffsize#:=13pt#; +staffsize#:=12.60pt#; input feta-autometric; fet_beginfont("parmesan", 13); diff --git a/mf/parmesan16.mf b/mf/parmesan16.mf index 76abf22974..0b6f322022 100644 --- a/mf/parmesan16.mf +++ b/mf/parmesan16.mf @@ -1,7 +1,7 @@ % parmesan16.mf % part of LilyPond's pretty-but-neat music font -staffsize#:=16pt#; +staffsize#:=15.87pt#; input feta-autometric; fet_beginfont("parmesan", 16); diff --git a/mf/parmesan23.mf b/mf/parmesan23.mf index c6710ccad1..4ab3732714 100644 --- a/mf/parmesan23.mf +++ b/mf/parmesan23.mf @@ -1,7 +1,7 @@ % parmesan23.mf % part of LilyPond's pretty-but-neat music font -staffsize#:=23pt#; +staffsize#:=22.45pt#; input feta-autometric; fet_beginfont("parmesan", 23); diff --git a/mf/parmesan26.mf b/mf/parmesan26.mf index 33c9ae714c..3b86b2232d 100644 --- a/mf/parmesan26.mf +++ b/mf/parmesan26.mf @@ -1,7 +1,7 @@ % parmesan26.mf % part of LilyPond's pretty-but-neat music font -staffsize#:=26pt#; +staffsize#:=25.20pt#; input feta-autometric; fet_beginfont("parmesan", 26); diff --git a/scm/chord-name.scm b/scm/chord-name.scm index 6ffecfa843..1bc5ba99ef 100644 --- a/scm/chord-name.scm +++ b/scm/chord-name.scm @@ -119,7 +119,7 @@ FOOBAR-MARKUP) if OMIT-ROOT is given and non-false. (define (is-req-chord? m) (and (memq 'event-chord (ly:get-mus-property m 'types)) - (not (equal? (ly:make-moment 0 1) (ly:get-music-length m))))) + (not (equal? ZERO-MOMENT (ly:music-length m))))) (let* ((elts (filter is-req-chord? (ly:get-mus-property seq 'elements))) (alist (map chord-to-exception-entry elts))) diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 978fb0f950..7f75bfb9d9 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -215,13 +215,13 @@ options include undefined and mensural. definition: music roman braces dynamic math ...") (grob-property-description 'font-name string? "file name for the font to load. Overrides all other font-X qualifiers.") -(grob-property-description 'font-design-size number? "partial font definition: exact font size in points FIXME: should override font-relative-size.") (grob-property-description 'font-magnification number? "Magnification of the font. If undefined, the default is @code{1.0}.") -(grob-property-description 'font-relative-size number? "partial font -definition: the relative size compared the `normal' size. 0 is -style-sheet's normal size, -1 is smaller, +1 is bigger.") +(grob-property-description 'font-size number? "font definition: the +relative size compared the `normal' size. 0 is style-sheet's normal +size, -1 is smaller, +1 is bigger. Each step of 1 is approximately +12% larger, 6 steps are exactly a factor 2 larger. Fractional values are allowed.") (grob-property-description 'font-series symbol? "partial font definition: medium, bold.") (grob-property-description 'font-shape symbol? "partial font definition: upright or italic.") diff --git a/scm/define-translator-properties.scm b/scm/define-translator-properties.scm index 16203d0ef2..2fd1825b49 100644 --- a/scm/define-translator-properties.scm +++ b/scm/define-translator-properties.scm @@ -332,6 +332,12 @@ auto string-selecting mechanism selects the highest string with a fret not less than minimumFret") (translator-property-description 'minimumVerticalExtent number-pair? "minimum vertical extent, same format as VerticalExtent") +(translator-property-description 'recordEventSequence procedure? + "Upon termination of this context, +this function is called with current context and a list of music +objects. The list of contains entries with start times, music objects +and whether they're processed in this context.") + (translator-property-description 'noDirection boolean? "Don't set directions by a2-engraver when part-combining.") (translator-property-description 'originalCentralCPosition integer? diff --git a/scm/document-functions.scm b/scm/document-functions.scm index 5b2a64455e..19b619b365 100644 --- a/scm/document-functions.scm +++ b/scm/document-functions.scm @@ -2,12 +2,15 @@ (ice-9 regex) ) +(define (dashify-underscores str) + (regexp-substitute/global #f "_" str 'pre "-" 'post)) + (define (format-c-header c-h) (regexp-substitute/global #f "," - (regexp-substitute/global #f "(SCM|\\)|\\() *" c-h 'pre "" 'post) - 'pre " " 'post) - ) + (regexp-substitute/global #f "(SCM|\\)|\\() *" (dashify-underscores c-h) + 'pre "" 'post) + 'pre " " 'post)) (define (document-scheme-function name c-header doc-string) (string-append @@ -21,8 +24,7 @@ (lambda (key val prior) (cons (cons key val) prior) ) - '() (ly:get-all-function-documentation)) - ) + '() (ly:get-all-function-documentation))) (define (all-scheme-functions-doc) (let* diff --git a/scm/font.scm b/scm/font.scm index 22c7b5f470..41784a0bc2 100644 --- a/scm/font.scm +++ b/scm/font.scm @@ -6,227 +6,112 @@ ;;; (c) 2000--2003 Jan Nieuwenhuizen ;;; -(define (font-field name font-descr) - (list-ref - font-descr - (cond - ((eq? name 'font-relative-size) 0) - ((eq? name 'font-series) 1) - ((eq? name 'font-shape) 2) - ((eq? name 'font-family) 3) - ((eq? name 'font-design-size) 4) - (else (ly:warning "unknown font field name")) - ) - )) - +;; Should separate default sizes +;; into separate list/alist ? + + +" +Each entry in this vector has the following format + + + (cons + #(QUALIFIERS) + (cons DEFAULT-SIZE + #(SIZE-FONT-ENTRIES... ) )) + +where each SIZE-FONT-ENTRY is + + (cons DESIGN-SIZE FONT-NAME) + +or + + (cons DESIGN-SIZE (list FONT-NAME1 FONT-NAME2 .. )) + +" + + +(define-public paper20-font-vector + '((#(medium upright number) . + (10 . #((10.0 . "feta-nummer10")))) + (#(medium upright roman) . + (10.0 . #((6.0 . "cmr6") + (8.0 . "cmr8") + (10.0 . "cmr10") + (17.0 . "cmr17") + ))) + (#(* * music). + (20.0 . #((11.22 . ("feta11" "parmesan11")) + (12.60 . ("feta13" "parmesan13")) + (14.14 . ("feta14" "parmesan14")) + (15.87 . ("feta16" "parmesan16")) + (17.82 . ("feta18" "parmesan18")) + (20.0 . ("feta20" "parmesan20")) + (22.45 . ("feta23" "parmesan23")) + (25.20 . ("feta26" "parmesan26")) + ))) + (#(medium upright sans) . + (10.0 . #((8.0 . "cmss8") + (10.0 . "cmss10") + (12.0 . "cmss12") + (17.0 . "cmss17") + ))) + (#(medium upright typewriter) . + (10.0 . #((8.0 . "cmtt8") + (10.0 . "cmtt10") + (12.0 . "cmtt12") + ))) + (#(bold italic roman) . + (10.0 . #((8.0 . "cmbxti7") + (10.0 . "cmbxti10") + (14.0 . "cmbxti14") + ))) + (#(medium italic roman) . + (10.0 . #((7.0 . "cmti7") + (10.0 . "cmti10") + (12.0 . "cmti12") + ))) + (#(bold upright roman) . + (10.0 . #((6.0 . "cmbx6") + (8.0 . "cmbx8") + (10.0 . "cmbx10") + (12.0 . "cmbx12") + ))) + (#(medium caps roman) . + (10.0 . #((10.0 . "cmcsc10")))) + + ;; this is a little pointless, since feta-din scales linearly + (#(* * dynamic) . + (14.0 . #((8.0 . "feta-din10") + (10.0 . "feta-din10") + (14.0 . "feta-din14") + (17.0 . "feta-din17") + ))) + (#(* * math) . + (10.0 . #((10.0 . "msam10")))) + )) + +(define (scale-font-entry entry factor) + (cons + (car entry) + (cons (* (cadr entry) factor) + (cddr entry)))) (define size-independent-fonts - `( - ((* * * braces *) . ("feta-braces00" - "feta-braces10" - "feta-braces20" - "feta-braces30" - "feta-braces40" - "feta-braces50" - "feta-braces60" - "feta-braces70" - "feta-braces80") ))) - -;; FIXME: what about this comment?: - -;; font-lookup seems a little inefficient -- walking this entire list -;; for a single font. -;; -;; should really have name/pt size at the front of the list. -;; (also tried to vary the order of this list, with little effect) -;; -;; (font-relative-size font-series font-shape font-family -;; font-design-size) - -(define paper20-style-sheet-alist - '( - ;; why are font file names strings, not symbols? - ((3 medium upright number 13) . "feta-nummer13") - ((2 medium upright number 13) . "feta-nummer13") - ((1 medium upright number 11) . "feta-nummer11") - ((0 medium upright number 10) . "feta-nummer10") - ((-1 medium upright number 8) . "feta-nummer8") - ((-2 medium upright number 7) . "feta-nummer7") - ((-3 medium upright number 6) . "feta-nummer6") - ((-4 medium upright number 5) . "feta-nummer5") - ((-5 medium upright number 4) . "feta-nummer4") - - ((4 medium upright roman 17) . "cmr17") - ((3 medium upright roman 17) . "cmr17") - ((2 medium upright roman 12) . "cmr12") - ((1 medium upright roman 12) . "cmr12") - ((0 medium upright roman 10) . "cmr10") - ((-1 medium upright roman 8) . "cmr8" ) - ((-2 medium upright roman 7) . "cmr7" ) - ((-3 medium upright roman 6) . "cmr6" ) - ((-4 medium upright roman 5) . "cmr5" ) - ((-5 medium upright roman 5) . "cmr5" ) - - ((4 medium upright sans 17) . "cmss17") - ((3 medium upright sans 17) . "cmss17") - ((2 medium upright sans 14) . "cmss14") - ((1 medium upright sans 12) . "cmss12") - ((0 medium upright sans 10) . "cmss10") - ((-1 medium upright sans 9) . "cmss9" ) - ((-2 medium upright sans 8) . "cmss8" ) - ((-3 medium upright sans 7) . "cmss7" ) - ((-4 medium upright sans 6) . "cmss6" ) - ((-5 medium upright sans 5) . "cmss5" ) - - ((3 medium italic roman 12) . "cmti12") - ((2 medium italic roman 12) . "cmti12") - ((1 medium italic roman 12) . "cmti12") ;;; ugh. Should add magnification here! - ((0 medium italic roman 10) . "cmti10") - ((-1 medium italic roman 8) . "cmti8") - ((-2 medium italic roman 7) . "cmti7") - ((-3 medium italic roman 6) . "cmti6") - ((-4 medium italic roman 5) . "cmti5") - ((-5 medium italic roman 5) . "cmti5") - - ;;; cmbx17 is sauter, not commonly available as Type1. - ((4 bold upright roman 17) . "cmbx17") - ((3 bold upright roman 17) . "cmbx17") - - ((2 bold upright roman 14) . "cmbx14") - ((1 bold upright roman 12) . "cmbx12") - ((0 bold upright roman 10) . "cmbx10") - ((-1 bold upright roman 8) . "cmbx8") - ((-2 bold upright roman 7) . "cmbx7") - ((-3 bold upright roman 6) . "cmbx6") - ((-4 bold upright roman 5) . "cmbx5") - ((-5 bold upright roman 5) . "cmbx5") - - - ((2 bold italic roman 12) . "cmbxti12") - ((1 bold italic roman 12) . "cmbxti12") - ((0 bold italic roman 10) . "cmbxti10") - - ((-1 bold italic roman 8) . "cmbxti8") - ((-2 bold italic roman 7) . "cmbxti7") - ((-3 bold italic roman 6) . "cmbxti6") - ((-4 bold italic roman 5) . "cmbxti5") - ((-5 bold italic roman 5) . "cmbxti5") - - ((4 medium upright typewriter 17) . "cmtt17") - ((3 medium upright typewriter 17) . "cmtt17") - ((2 medium upright typewriter 12) . "cmtt12") - ((1 medium upright typewriter 12) . "cmtt12") - ((0 medium upright typewriter 10) . "cmtt10") - ((-1 medium upright typewriter 8) . "cmtt8" ) - ((-2 medium upright typewriter 7) . "cmtt7" ) - ((-3 medium upright typewriter 6) . "cmtt6" ) - ((-4 medium upright typewriter 5) . "cmtt5" ) - ((-5 medium upright typewriter 5) . "cmtt5" ) - - ((3 medium caps roman 12) . "cmcsc12") - ((2 medium caps roman 12) . "cmcsc12") - ((1 medium caps roman 12) . "cmcsc12") - ((0 medium caps roman 10) . "cmcsc10") - ((-1 medium caps roman 8) . "cmcsc8") - ((-2 medium caps roman 7) . "cmcsc7") - ((-3 medium caps roman 7) . "cmcsc7") - - ((3 * * dynamic 19) . "feta-din19") - ((2 * * dynamic 19) . "feta-din19") - ((1 * * dynamic 17) . "feta-din17") - ((0 * * dynamic 14) . "feta-din14") - ((-1 * * dynamic 12) . "feta-din12") - ((-2 * * dynamic 9) . "feta-din9") - ((-3 * * dynamic 8) . "feta-din8") - ((-4 * * dynamic 7) . "feta-din7") - ((-5 * * dynamic 6) . "feta-din6") - - ((2 * * music 26) . ("feta26" "parmesan26")) - ((1 * * music 23) . ("feta23" "parmesan23")) - ((0 * * music 20) . ("feta20" "parmesan20")) - ((-1 * * music 16) . ("feta16" "parmesan16")) - ((-2 * * music 13) . ("feta13" "parmesan13")) - ((-3 * * music 11) . ("feta11" "parmesan11")) - ((-4 * * music 11) . ("feta11" "parmesan11")) - - ((2 * * ancient 26) . ("feta26" "parmesan26")) - ((1 * * ancient 23) . ("feta23" "parmesan23")) - ((0 * * ancient 20) . ("feta20" "parmesan20")) - ((-1 * * ancient 16) . ("feta16" "parmesan16")) - ((-2 * * ancient 13) . ("feta13" "parmesan13")) - ((-3 * * ancient 11) . ("feta11" "parmesan11")) - ((-4 * * ancient 11) . ("feta11" "parmesan11")) - - ((0 * * math 10) . "msam10") - ((-1 * * math 10) . "msam10") - ((-2 * * math 10) . "msam10") - ((-3 * * math 10) . "msam10") - )) - -;; -(define (change-relative-size font-desc decrement) - "return a FONT-DESCR with relative size decremented by DECREMENT" - - (if (number? (car font-desc)) - (cons (- (car font-desc) decrement) (cdr font-desc)) - font-desc) - ) - -(define (change-rhs-size font-desc from to ) - (cons (car font-desc) - (regexp-substitute/global #f from (cdr font-desc) 'pre to 'post))) - - -(define (change-style-sheet-relative-size sheet x) - (map-alist-keys (lambda (descr) (change-relative-size descr x)) sheet)) - - -;; make style sheet for each paper version. -(define font-list-alist - (map-alist-vals (lambda (x) (change-style-sheet-relative-size - paper20-style-sheet-alist x)) - '((paper11 . -3) - (paper13 . -2) - (paper16 . -1) - (paper20 . 0) - (paper23 . 1) - (paper26 . 2) - ))) - -;; -;; make a kludged up paper-19 style sheet. Broken by virtual fonts. -;; -(if #f - (set! font-list-alist - (cons - (cons - 'paper19 - (map (lambda (x) (change-rhs-size x "20" "19")) - paper20-style-sheet-alist)) - font-list-alist))) - -(define-public (make-font-list sym) + '((#(* * braces) . + (10 . #((10.0 . ("feta-braces00" + "feta-braces10" + "feta-braces20" + "feta-braces30" + "feta-braces40" + "feta-braces50" + "feta-braces60" + "feta-braces70" + "feta-braces80"))))))) + +(define-public (scale-font-list factor) (append size-independent-fonts - (cdr (assoc sym font-list-alist)))) - - -;;; ascii-script font init -(define as-font-sheet-alist - '((as5 . (((* * * braces *) . ("as-braces9")) - ((* * * number *) . "as-number1") - ((0 * * music *) . ("as5")) - ((0 * * roman *) . "as-dummy"))) - (as9 . (((* * * braces *) . ("as-braces9")) - ((0 medium upright number 10) . "as-number4") - ((* * * number 5) . "as-number1") - ((0 * * music *) . ("as9")) - ((0 * * roman *) . "as-dummy"))))) - -(define-public (as-make-font-list sym) - (set! font-list-alist - (append font-list-alist as-font-sheet-alist)) - (make-font-list sym)) - - - + (map (lambda (y) (scale-font-entry y factor)) paper20-font-vector) + )) + +; diff --git a/scm/lily.scm b/scm/lily.scm index cec78e35ee..9ceb5333ed 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -77,6 +77,8 @@ (define-public DOUBLE-SHARP 4) (define-public SEMI-TONE 2) +(define-public ZERO-MOMENT (ly:make-moment 0 1)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; lily specific variables. (define-public default-script-alist '()) @@ -127,6 +129,14 @@ handle (chain-assoc x (cdr alist-list)))))) +(define (chain-assoc-get x alist-list default) + (if (null? alist-list) + default + (let* ((handle (assoc x (car alist-list)))) + (if (pair? handle) + (cdr handle) + (chain-assoc-get x (cdr alist-list) default))))) + (define (map-alist-vals func list) "map FUNC over the vals of LIST, leaving the keys." diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 5af90d2260..c66215d170 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -711,10 +711,28 @@ Rest can contain a list of beat groupings m) (define-public toplevel-music-functions - (list check-start-chords + (list +;; check-start-chords ; ; no longer needed with chord syntax. voicify-music (lambda (x) (music-map glue-mm-rest-texts x)) ; switch-on-debugging )) + + +;;;;;;;;;;;;;;;;; +;; lyrics + +(define (apply-durations lyric-music durations) + (define (apply-duration music) + (if (and (not (equal? (ly:music-length music) ZERO-MOMENT)) + (ly:duration? (ly:get-mus-property music 'duration))) + (begin + (ly:set-mus-property! music 'duration (car durations)) + (set! durations (cdr durations)) + ))) + + (music-map apply-duration lyric-music)) + + diff --git a/scm/new-markup.scm b/scm/new-markup.scm index 8b7d8e91c1..1d4627aefd 100644 --- a/scm/new-markup.scm +++ b/scm/new-markup.scm @@ -104,12 +104,12 @@ for the reader. (define-public (finger-markup paper props . rest) (interpret-markup paper - (cons (list '(font-relative-size . -3) + (cons (list '(font-size . -4) '(font-family . number)) props) (car rest))) -(define-public fontsize-markup (set-property-markup 'font-relative-size)) +(define-public fontsize-markup (set-property-markup 'font-size)) (define-public magnify-markup (set-property-markup 'font-magnification)) (define-public bold-markup @@ -331,7 +331,7 @@ for DIR, you can obtain longer or shorter stems." "Syntax: \\super MARKUP. " (ly:molecule-translate-axis (interpret-markup paper - (cons '((font-relative-size . -2)) props) (car rest)) + (cons '((font-size . -3)) props) (car rest)) (* 0.5 (cdr (chain-assoc 'baseline-skip props))) Y) ) @@ -347,7 +347,7 @@ for DIR, you can obtain longer or shorter stems." "Syntax: \\sub MARKUP." (ly:molecule-translate-axis (interpret-markup paper - (cons '((font-relative-size . -2)) props) + (cons '((font-size . -3)) props) (car rest)) (* -0.5 (cdr (chain-assoc 'baseline-skip props))) Y) @@ -365,10 +365,8 @@ for DIR, you can obtain longer or shorter stems." "Horizontal brackets around its single argument. Syntax \\hbracket MARKUP." (let* - ( - (th 0.1) ;; todo: take from GROB. - (m (interpret-markup paper props (car rest))) - ) + ((th 0.1) ;; todo: take from GROB. + (m (interpret-markup paper props (car rest))) ) (bracketify-molecule m X th (* 2.5 th) th) )) @@ -376,10 +374,8 @@ for DIR, you can obtain longer or shorter stems." (define-public (bracket-markup paper props . rest) "Vertical brackets around its single argument. Syntax \\bracket MARKUP." (let* - ( - (th 0.1) ;; todo: take from GROB. - (m (interpret-markup paper props (car rest))) - ) + ((th 0.1) ;; todo: take from GROB. + (m (interpret-markup paper props (car rest))) ) (bracketify-molecule m Y th (* 2.5 th) th) )) @@ -407,9 +403,8 @@ for DIR, you can obtain longer or shorter stems." (define-public (smaller-markup paper props . rest) "Syntax: \\smaller MARKUP" (let* - ( - (fs (cdr (chain-assoc 'font-relative-size props))) - (entry (cons 'font-relative-size (- fs 1))) + ((fs (chain-assoc-get 'font-size props 0)) + (entry (cons 'font-size (- fs 1))) ) (interpret-markup paper (cons (list entry) props) @@ -419,9 +414,8 @@ for DIR, you can obtain longer or shorter stems." (define-public (bigger-markup paper props . rest) "Syntax: \\bigger MARKUP" (let* - ( - (fs (cdr (chain-assoc 'font-relative-size props))) - (entry (cons 'font-relative-size (+ fs 1))) + ((fs (chain-assoc-get 'font-size props 0)) + (entry (cons 'font-size (+ fs 1))) ) (interpret-markup paper (cons (list entry) props) @@ -431,8 +425,7 @@ for DIR, you can obtain longer or shorter stems." (define-public (box-markup paper props . rest) "Syntax: \\box MARKUP" (let* - ( - (th 0.1) + ((th 0.1) (pad 0.2) (m (interpret-markup paper props (car rest))) ) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index f47c98bedd..e074366738 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -9,8 +9,7 @@ ; The TabNoteHead stem attachment function. (define (tablature-stem-attachment-function style duration) - (cons 0.0 0.5) ;; UGH! -) + (cons 0.0 0.5)) ; The TabNoteHead molecule callback. ; Create a text molecule @@ -30,9 +29,7 @@ (list-ref tuning (- string 1) ; remove 1 because list index starts at 0 and guitar string at 1. ) - ) - ) - ) + ) ) ) (define-public (hammer-molecule-callback grob) (let* ((note-collums (ly:get-grob-property grob 'note-columns)) @@ -59,9 +56,7 @@ ) (ly:molecule-combine-at-edge slur 1 1 text -0.6) - ) - ) - ) + ) ) ) @@ -276,6 +271,5 @@ centered, X==1 is at the right, X == -1 is at the left." (if (equal? result #f) (ly:warn (string-append "Unknown bar glyph: `" glyph "'")) (index-cell (cdr result) dir)) - ) - ) + ) ) diff --git a/scm/output-ps.scm b/scm/output-ps.scm index bd5a5df1f2..bf42f7e22c 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -233,7 +233,6 @@ (string-append "%!PS-Adobe-3.0\n" "%%Creator: " creator generate "\n")) - (define (header-end) (string-append ;; URG: now we can't use scm output without Lily @@ -243,8 +242,8 @@ "{ exch pop //systemdict /run get exec } " ;; ps-testing wreaks havoc when used with lilypond-book. ;; -- is this still true with new modules system? - ;; (if (defined? 'ps-testing) "\n /testing true def" "") - ;; "\n /testing true def" +;; (if (defined? 'ps-testing) "\n /testing true def" "") + ; "\n /testing true def" )) (define (lily-def key val) diff --git a/scm/to-xml.scm b/scm/to-xml.scm index f14e40e329..b53b2f5e5f 100644 --- a/scm/to-xml.scm +++ b/scm/to-xml.scm @@ -1,12 +1,9 @@ -(use-modules (ice-9 regex) - (srfi srfi-1)) - -;; should make module? +(use-modules (ice-9 regex) + (srfi srfi-1) + (oop goops)) " - - Todo: this is a quick hack; it makes more sense to define a GOOPS class of a documentnode (similar to how ; the documentation is generated.) @@ -24,11 +21,110 @@ is then separated. - - - " +(define-class () + (name #:init-value "" #:accessor node-name #:init-keyword #:name) + (value #:init-value "" #:accessor node-value #:init-keyword #:value) + (attributes #:init-value '() + #:accessor node-attributes + #:init-keyword #:attributes) + (children #:init-value '() + #:accessor node-children + #:init-keyword #:children)) + +(define node-names + '((NoteEvent . note) + (SequentialMusic . measure) + + ;;ugh + (pitch . pitch) + (duration . duration) + (octave . octave) + (step . step) + )) + +(define (assoc-get-default key alist default) + "Return value if KEY in ALIST, else DEFAULT." + (let ((entry (assoc key alist))) + (if entry (cdr entry) default))) + +(define (musicxml-node->string node) + (let ((xml-name (assoc-get-default (node-name node) node-names #f))) + (string-append + (if xml-name (open-tag xml-name '() '()) "") + (if (equal? (node-value node) "") + (string-append + (if xml-name "\n" "") + (apply string-append (map musicxml-node->string (node-children node)))) + (node-value node)) + (if xml-name (close-tag xml-name) "") + (if xml-name "\n" "")))) + +(define (xml-node->string node) + (string-append + "\n" + (open-tag (node-name node) (node-attributes node) '()) + (if (equal? (node-value node) "") + (string-append + (apply string-append (map xml-node->string (node-children node)))) + (node-value node)) + "\n" + (close-tag (node-name node)))) + +(define (musicxml-duration->xml-node d) + (make + #:name 'duration + #:value (number->string (ash 1 (ly:duration-log d))))) + +(define (duration->xml-node d) + (make + #:name 'duration + ;; #:value (number->string (ash 1 (ly:duration-log d))))) + #:attributes `((log . ,(ly:duration-log d)) + (dots . ,(ly:duration-dot-count d)) + (numer . ,(car (ly:duration-factor d))) + (denom . ,(cdr (ly:duration-factor d)))))) + +(define (musicxml-pitch->xml-node p) + (make + #:name 'pitch + #:children + (list + (make + #:name 'step + #:value (list-ref '("C" "D" "E" "F" "G" "A" "B") + (ly:pitch-notename p))) + (make + #:name 'octave + #:value (number->string (ly:pitch-octave p)))))) + +(define (pitch->xml-node p) + (make + #:name 'pitch + #:attributes `((octave . ,(ly:pitch-octave p)) + (notename . ,(ly:pitch-notename p)) + (alteration . ,(ly:pitch-alteration p))))) + +(define (music->xml-node music) + (let* ((name (ly:get-mus-property music 'name)) + (e (ly:get-mus-property music 'element)) + (es (ly:get-mus-property music 'elements)) + (mprops (ly:get-mutable-properties music)) + (d (ly:get-mus-property music 'duration)) + (p (ly:get-mus-property music 'pitch)) + (ignore-props '(origin elements duration pitch element))) + + (make + #:name name + #:children + (apply + append + (if (ly:pitch? p) (list (pitch->xml-node p)) '()) + (if (ly:duration? d) (list (duration->xml-node d)) '()) + (if (pair? es) (map music->xml-node es) '()) + (if (ly:music? e) (list (music->xml-node e)) '()) + '())))) (define (dtd-header) (string-append @@ -87,27 +183,6 @@ is then separated. ") - - -(define (dump-duration d port) - (display (open-tag 'duration - `((log . ,(ly:duration-log d)) - (dots . ,(ly:duration-dot-count d)) - (numer . ,(car (ly:duration-factor d))) - (denom . ,(cdr (ly:duration-factor d))) - ) - '() ) port) - (display (close-tag 'duration) port)) - -(define (dump-pitch p port) - (display (open-tag 'pitch - `((octave . ,(ly:pitch-octave p)) - (notename . ,(ly:pitch-notename p)) - (alteration . ,(ly:pitch-alteration p)) - ) - '() ) port) - (display (close-tag 'pitch) port)) - ;; should use macro (define (assert x) (if x @@ -152,45 +227,11 @@ is then separated. (string-append "<" (symbol->string tag) - (apply string-append - (map dump-attr (filter candidate? attrs))) - ">\n") - - ) -(define (close-tag name) - (string-append "string name) ">\n") - ) - -(define (music-to-xml-helper music port) - (let* - ( - (name (ly:get-mus-property music 'name)) - (e (ly:get-mus-property music 'element)) - (es (ly:get-mus-property music 'elements)) - (mprops (ly:get-mutable-properties music)) - (p (ly:get-mus-property music 'pitch)) - (d (ly:get-mus-property music 'duration)) - (ignore-props '(origin elements duration pitch element)) - ) + (apply string-append (map dump-attr (filter candidate? attrs))) + ">")) - ;; As almost everything is music; is - ;; probably better than ? - - (display (open-tag 'music (cons `(type . ,name) mprops) ignore-props) - port) - (if (ly:duration? d) - (dump-duration d port)) - (if (ly:pitch? p) - (dump-pitch p port)) - (if (pair? es) - (map (lambda (x) (music-to-xml-helper x port)) es) - ) - - (if (ly:music? e) - (begin - (music-to-xml-helper e port))) - (display (close-tag 'music) port) - )) +(define (close-tag name) + (string-append "string name) ">")) (define-public (music-to-xml music port) "Dump XML-ish stuff to PORT." @@ -200,5 +241,20 @@ is then separated. ;; (display (dtd-header) port) (display (open-tag 'music '((type . score)) '()) port) - (music-to-xml-helper music port) + (display (xml-node->string (music->xml-node music)) port) (display (close-tag 'music) port)) + +(define-public (music-to-musicxml music port) + "Dump MusicXML-ish stuff to PORT." + + ;; dtd contains # -- This confuses tex during make web. + ;; + ;; (display (dtd-header) port) + + (define pitch->xml-node musicxml-pitch->xml-node) + (define duration->xml-node musicxml-duration->xml-node) + + (display (open-tag 'music '((type . score)) '()) port) + (display (musicxml-node->string (music->xml-node music)) port) + (display (close-tag 'music) port)) + diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index ee781c5332..2f8184eed7 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -1603,13 +1603,19 @@ conversions.append (((1,9,8), conv, """dash-length -> dash-fraction""")) def conv (str): - if re.search ("up-to-staff", str) : - sys.stderr.write ("up-to-staff was removed. Use stem-end-position instead. ") - raise FatalConversionError () - + def func(match): + return "#'font-size = #%d" % (2*string.atoi (match.group (1))) + + str =re.sub (r"#'font-relative-size\s*=\s*#([0-9-]+)", func, str) + return str + +conversions.append (((2,1,1), conv, """font-relative-size -> font-size""")) + +def conv (str): + str =re.sub (r"ly:get-music-length", "ly:music-length", str) return str -conversions.append (((2,0,1), conv, """dash-length -> dash-fraction""")) +conversions.append (((2,1,2), conv, """ly:get-music-length -> ly:music-length""")) ################################ # END OF CONVERSIONS diff --git a/tex/GNUmakefile b/tex/GNUmakefile index b58a7e55ce..8d3554e52c 100644 --- a/tex/GNUmakefile +++ b/tex/GNUmakefile @@ -11,6 +11,7 @@ INSTALLATION_FILES=$(TEX_FILES) include $(depth)/make/stepmake.make $(outdir)/music-drawing-routines.ps: $(depth)/ps/music-drawing-routines.ps - -cp $< $@ + rm -f $@ + -ln $< $@ all: $(INSTALLATION_FILES)