From f372c695a52cf83ea00ff3be40acc542b4d46cbd Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sun, 3 Nov 2013 15:01:10 +0100 Subject: [PATCH] Issue 355: \repeat bar lines get messed up % the second repeat should start at the beginning of a bar, not % continue from the incomplete bar in the first ending. \version "2.17.30" \new Staff \relative { \partial 4 \repeat volta 4 { e' | c2 d2 | e2 f2 | } \alternative { { g4 g g } { a a a a } } a b2. } --- lily/volta-repeat-iterator.cc | 40 ++++++++++++++++++++++++++++++- ly/engraver-init.ly | 1 + scm/define-context-properties.scm | 3 +++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/lily/volta-repeat-iterator.cc b/lily/volta-repeat-iterator.cc index 2e386e6fd1..3e6f58efda 100644 --- a/lily/volta-repeat-iterator.cc +++ b/lily/volta-repeat-iterator.cc @@ -33,17 +33,26 @@ protected: virtual void next_element (bool); virtual void construct_children (); virtual void process (Moment); + virtual void derived_mark () const; bool first_time_; int alt_count_; int rep_count_; int done_count_; + SCM alt_restores_; }; Volta_repeat_iterator::Volta_repeat_iterator () { done_count_ = alt_count_ = rep_count_ = 0; first_time_ = true; + alt_restores_ = SCM_EOL; +} + +void +Volta_repeat_iterator::derived_mark () const +{ + scm_gc_mark (alt_restores_); } SCM @@ -95,12 +104,41 @@ Volta_repeat_iterator::next_element (bool side_effect) if (alt_count_) { string repstr = to_string (rep_count_ - alt_count_ + done_count_) + "."; - if (done_count_ > 1) + if (done_count_ <= 1) { + alt_restores_ = SCM_EOL; + if (to_boolean (get_outlet ()->get_property ("timing"))) + { + for (SCM lst = get_outlet ()->get_property ("alternativeRestores"); + scm_is_pair (lst); + lst = scm_cdr (lst)) + { + SCM res = SCM_EOL; + Context *t = get_outlet ()->where_defined (scm_car (lst), + &res); + if (t) + { + alt_restores_ = scm_cons + (scm_list_3 (t->self_scm (), scm_car (lst), res), + alt_restores_); + } + } + } + } + else + { + add_repeat_command (scm_list_n (ly_symbol2scm ("volta"), SCM_BOOL_F, SCM_UNDEFINED)); if (done_count_ - 1 < alt_count_) add_repeat_command (ly_symbol2scm ("end-repeat")); + + if (to_boolean (get_outlet ()->get_property ("timing"))) + { + for (SCM p = alt_restores_; scm_is_pair (p); p = scm_cdr (p)) + scm_apply_0 (ly_lily_module_constant ("ly:context-set-property!"), + scm_car (p)); + } } if (done_count_ == 1 && alt_count_ < rep_count_) diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 9c8547dd7d..9ff53bed6c 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -609,6 +609,7 @@ automatically when an output definition (a @code{\\score} or doubleRepeatType = #":..:" startRepeatType = #".|:" endRepeatType = #":|." + alternativeRestores = #'(measurePosition measureLength) barNumberVisibility = #first-bar-number-invisible-and-no-parenthesized-bar-numbers barNumberFormatter = #robust-bar-number-function clefTranspositionFormatter = #clef-transposition-markup diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index 20d77ea72f..073c714097 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -60,6 +60,9 @@ vertical alignment.") numbers. Can be @code{numbers} for going back to the same number or @code{numbers-with-letters} for going back to the same number with letter suffixes. No setting will not go back in measure-number time.") + (alternativeRestores ,symbol-list? "Timing variables that are +restored to their value at the end of the first alternative in +subsequent alternatives.") (associatedVoice ,string? "Name of the @code{Voice} that has the melody for this @code{Lyrics} line.") (autoAccidentals ,list? "List of different ways to typeset an -- 2.39.5