From: Han-Wen Nienhuys Date: Tue, 25 May 2004 20:47:11 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: release/2.3.2~6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=712b6f387c98454e0fc8c5b6c7f0848acf4b29ec;p=lilypond.git *** empty log message *** --- diff --git a/ChangeLog b/ChangeLog index 4f0b344a1f..312fedf22b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,18 @@ 2004-05-25 Han-Wen Nienhuys + * scripts/lilypond.py (run_dvips): only add papersize if present. + + * lily/accidental-engraver.cc (update_local_key_signature): new + function, fold code from initialize() and process_music(). + (update_local_key_signature): use deep copy. This fixes one + problem from custom-key-signatures.ly. + (number_accidentals_from_sig): tighter check for + accidental-too-old. + + * ly/engraver-init.ly: remove localKeySignature + definition from ChoirStaff, StaffGroup, Score. + * lily/percent-repeat-engraver.cc (try_music): add moments for barlines too. Fixes: skipbars-percent-repeat.ly. diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index 735e9ff831..4ffd0586b8 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -41,6 +41,11 @@ Accidental_entry::Accidental_entry () } struct Accidental_engraver : Engraver { + + + int get_bar_number (); + void update_local_key_signature (); + protected: TRANSLATOR_DECLARATIONS (Accidental_engraver); virtual void process_music (); @@ -51,8 +56,8 @@ protected: virtual void finalize (); public: - Protected_scm last_keysig_; - + Protected_scm last_keysig_; // ugh. + /* Urgh. Since the accidentals depend on lots of variables, we have to store all information before we can really create the accidentals. @@ -64,15 +69,22 @@ public: Array accidentals_; Link_array ties_; - - SCM get_bar_num (); }; +/* + TODO: + + ugh, it is not clear what properties are mutable and which + aren't. eg. localKeySignature is changed at runtime, which means + that references in grobs should always store ly_deep_copy ()s of + those. + */ + static void set_property_on_children (Context * trans, const char * sym, SCM val) { - trans->set_property (sym, val); + trans->set_property (sym, ly_deep_copy (val)); for (SCM p = trans->children_contexts (); ly_c_pair_p (p); p = ly_cdr (p)) { Context *trg = unsmob_context (ly_car (p)); @@ -86,19 +98,30 @@ Accidental_engraver::Accidental_engraver () last_keysig_ = SCM_EOL; } + void -Accidental_engraver::initialize () +Accidental_engraver::update_local_key_signature () { last_keysig_ = get_property ("keySignature"); + set_property_on_children (context (), "localKeySignature", last_keysig_); - Context * trans_ = context (); - while (trans_) + Context * trans = context ()->get_parent_context (); + + /* + Huh. Don't understand what this is good for. --hwn. + */ + while (trans && trans->where_defined (ly_symbol2scm ("localKeySignature"))) { - trans_ -> set_property ("localKeySignature", - ly_deep_copy (last_keysig_)); - trans_ = trans_->get_parent_context (); + trans->set_property ("localKeySignature", + ly_deep_copy (last_keysig_)); + trans = trans->get_parent_context (); } - set_property_on_children (context (),"localKeySignature", last_keysig_); +} + +void +Accidental_engraver::initialize () +{ + update_local_key_signature (); } /* @@ -111,40 +134,55 @@ Accidental_engraver::initialize () */ static int number_accidentals_from_sig (bool *different, - SCM sig, Pitch *pitch, SCM curbarnum, SCM lazyness, + SCM sig, Pitch *pitch, int curbarnum, SCM lazyness, bool ignore_octave) { int n = pitch->get_notename (); int o = pitch->get_octave (); int a = pitch->get_alteration (); - int curbarnum_i = ly_scm2int (curbarnum); - int accbarnum_i = 0; + int accbarnum = -1; - SCM prev; - if (ignore_octave) - prev = ly_assoc_cdr (scm_int2num (n), sig); - else - prev = scm_assoc (scm_cons (scm_int2num (o), scm_int2num (n)), sig); - - /* should really be true unless prev == SCM_BOOL_F */ - if (ly_c_pair_p (prev) && ly_c_pair_p (ly_cdr (prev))) + SCM prevs[3]; + int bar_nums[3] = {-1,-1,-1}; + int prev_idx = 0; + + if (!ignore_octave) { - accbarnum_i = ly_scm2int (ly_cddr (prev)); - prev = scm_cons (ly_car (prev), ly_cadr (prev)); + prevs[prev_idx] = scm_assoc (scm_cons (scm_int2num (o), scm_int2num (n)), sig); + + if (ly_c_pair_p (prevs[prev_idx])) + prev_idx++; } - /* If an accidental was not found or the accidental was too old */ - if (prev == SCM_BOOL_F || - (ly_c_number_p (lazyness) && curbarnum_i > accbarnum_i + ly_scm2int (lazyness))) - prev = scm_assoc (scm_int2num (n), sig); - + prevs[prev_idx] = scm_assoc (scm_int2num (n), sig); + if (ly_c_pair_p (prevs[prev_idx])) + prev_idx++; - SCM prev_acc = (prev == SCM_BOOL_F) ? scm_int2num (0) : ly_cdr (prev); + for (int i= 0; i < prev_idx; i++) + { + if (ly_c_pair_p (prevs[i]) + && ly_c_pair_p (ly_cdr (prevs[i]))) + { + bar_nums[i] = ly_scm2int (ly_cddr (prevs[i])); + prevs[i] = scm_cons (ly_car (prevs[i]), ly_cadr (prevs[i])); + } + } + - int p = ly_c_number_p (prev_acc) ? ly_scm2int (prev_acc) : 0; + int p = 0; + for (int i= 0; i < prev_idx; i++) + { + if (accbarnum < 0 + || (ly_c_number_p (lazyness) + && curbarnum > accbarnum + ly_scm2int (lazyness))) + { + p = ly_scm2int (ly_cdr (prevs[i])); + break; + } + } int num; - if (a == p && ly_c_number_p (prev_acc)) + if (a == p) num = 0; else if ( (abs (a)get_alteration (); SCM on_s = scm_cons (scm_int2num (o), scm_int2num (n)); - while (origin) + while (origin && origin->where_defined (ly_symbol2scm ("localKeySignature"))) { /* huh? we set props all the way to the top? @@ -393,7 +432,7 @@ Accidental_engraver::stop_translation_timestep () that of the tied note and of the key signature. */ localsig = ly_assoc_front_x - (localsig, on_s, scm_cons (SCM_BOOL_T, barnum)); + (localsig, on_s, scm_cons (SCM_BOOL_T, scm_int2num (barnum))); change = true; } @@ -404,13 +443,14 @@ Accidental_engraver::stop_translation_timestep () noteheads with the same notename. */ localsig = ly_assoc_front_x - (localsig, on_s, scm_cons (scm_int2num (a), barnum)); + (localsig, on_s, scm_cons (scm_int2num (a), scm_int2num (barnum))); change = true; } if (change) origin->set_property ("localKeySignature", localsig); + origin = origin->get_parent_context (); } } @@ -469,15 +509,7 @@ Accidental_engraver::process_music () */ if (last_keysig_ != sig) { - Context * trans_ = context (); - while (trans_) - { - trans_ -> set_property ("localKeySignature", ly_deep_copy (sig)); - trans_ = trans_->get_parent_context (); - } - set_property_on_children (context (),"localKeySignature", sig); - - last_keysig_ = sig; + update_local_key_signature (); } } diff --git a/lily/book-paper-def.cc b/lily/book-paper-def.cc index f67aad2131..42d8bd623d 100644 --- a/lily/book-paper-def.cc +++ b/lily/book-paper-def.cc @@ -214,3 +214,13 @@ Book_paper_def::c_variable (String s) const { return lookup_variable (ly_symbol2scm (s.to_str0 ())); } + + +LY_DEFINE (ly_book_paper_def_scope, "ly:bookpaper-def-scope", + 1, 0,0, (SCM def), + "Get the variable scope inside @var{def}.") +{ + Book_paper_def *op = unsmob_book_paper_def (def); + SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition"); + return op->scope_; +} diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index 2007350427..f5e4a02d68 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -72,7 +72,6 @@ Key_engraver::create_key (bool def) if (to_boolean (get_property ("printKeyCancellation"))) item_->set_property ("old-accidentals", get_property ("lastKeySignature")); item_->set_property ("new-accidentals", get_property ("keySignature")); - } if (!def) @@ -135,7 +134,8 @@ Key_engraver::process_music () void Key_engraver::stop_translation_timestep () { - item_ = 0; + item_ = 0; + context ()->set_property ("lastKeySignature", get_property ("keySignature")); } @@ -172,7 +172,6 @@ void Key_engraver::start_translation_timestep () { key_ev_ = 0; - context ()->set_property ("lastKeySignature", get_property ("keySignature")); } diff --git a/lily/key-signature-interface.cc b/lily/key-signature-interface.cc index 4666d4982a..7f9a96b1d7 100644 --- a/lily/key-signature-interface.cc +++ b/lily/key-signature-interface.cc @@ -46,9 +46,6 @@ const int NATURAL_TOP_PITCH = 4; the thinking to other parties. - TODO: put this in Scheme - - - lots of values trivially shared (key doesn't change very - often). Compute those once, and use that as cache for the rest. TODO: can we do without c0pos? it's partly musical. @@ -74,6 +71,7 @@ alteration_pos (SCM what, int alter, int c0p) { p -= 7; /* Typeset below c_position */ } + /* Provide for the four cases in which there's a glitch it's a hack, but probably not worth the effort of finding a nicer solution. diff --git a/ly/book-paper-defaults.ly b/ly/book-paper-defaults.ly index 42f29ddfef..198da70b59 100644 --- a/ly/book-paper-defaults.ly +++ b/ly/book-paper-defaults.ly @@ -66,4 +66,6 @@ #:fill-line (#:large #:bigger #:caps (get 'piece) ""))))))) + papersize = "a4" + } diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 19be19f652..fb85ddf42b 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -89,7 +89,6 @@ \name InnerChoirStaff \consists "System_start_delimiter_engraver" systemStartDelimiter = #'SystemStartBracket - localKeySignature = #'() \accepts "Staff" \accepts "DrumStaff" @@ -279,7 +278,6 @@ \context { \type "Engraver_group_engraver" \name InnerStaffGroup - localKeySignature = #'() \consists "Span_bar_engraver" \consists "Span_arpeggio_engraver" @@ -390,7 +388,6 @@ AncientRemoveEmptyStaffContext = \context { \context { \type Score_engraver \name Score - localKeySignature = #'() \description "This is the top level notation context. No other context can contain a @code{Score} context. This context diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 77dd2053b4..dbc8a67b67 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -75,11 +75,13 @@ (tex-number-def "lilypondpaper" 'outputscale (number->string (exact->inexact (ly:bookpaper-outputscale bookpaper)))) - (apply string-append - (map (lambda (x) (font-load-command bookpaper x)) - (ly:bookpaper-fonts bookpaper) - ))) -) + (tex-string-def "lilypondpapersize" 'papersize + (eval 'papersize (ly:bookpaper-def-scope bookpaper))) + (apply string-append + (map (lambda (x) (font-load-command bookpaper x)) + (ly:bookpaper-fonts bookpaper) + ))) + ) (define (unknown) "%\n\\unknown\n") diff --git a/scm/paper.scm b/scm/paper.scm index 1cc32532bd..b6ab3761a5 100644 --- a/scm/paper.scm +++ b/scm/paper.scm @@ -73,8 +73,6 @@ (module-define! m 'head-sep (* 4 mm)) (module-define! m 'foot-sep (* 4 mm)))) - - (define (internal-set-paper-size module name) (let* ((entry (assoc name paper-alist)) (is-paper? (module-defined? module '$is-paper)) diff --git a/scripts/lilypond.py b/scripts/lilypond.py index e9e9849201..cfe24015c9 100644 --- a/scripts/lilypond.py +++ b/scripts/lilypond.py @@ -486,7 +486,9 @@ def run_dvips (outbase, extra): leaving a PS file in OUTBASE.ps ''' #FIXME: papersize, orientation must come from lilypond-bin - opts = ' -t%s' % extra['papersize'][0] + + if extra['papersize']: + opts = ' -t%s' % extra['papersize'][0] if extra['orientation'] and extra['orientation'][0] == 'landscape': opts = opts + ' -tlandscape'