From: fred Date: Wed, 27 Mar 2002 00:48:39 +0000 (+0000) Subject: lilypond-1.3.127 X-Git-Tag: release/1.5.59~951 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=10329166e187f511f4043f5c596db12b645598ac;p=lilypond.git lilypond-1.3.127 --- diff --git a/input/bugs/repeat.ly b/input/bugs/repeat.ly new file mode 100644 index 0000000000..c9f7e36b6f --- /dev/null +++ b/input/bugs/repeat.ly @@ -0,0 +1,2 @@ + +\score { \context Staff \notes \repeat volta 3 c1 \alternative { d1 e1 }} diff --git a/input/regression/repeat-volta-skip-alternatives.ly b/input/regression/repeat-volta-skip-alternatives.ly new file mode 100644 index 0000000000..ed612cef84 --- /dev/null +++ b/input/regression/repeat-volta-skip-alternatives.ly @@ -0,0 +1,3 @@ +\score { \notes \context Voice { + \repeat volta 3 c1 + \alternative { d f } e4 } } diff --git a/lily/global-translator.cc b/lily/global-translator.cc index 61b724d40d..af8d804537 100644 --- a/lily/global-translator.cc +++ b/lily/global-translator.cc @@ -95,7 +95,8 @@ Global_translator::run_iterator_on_me (Music_iterator * iter) w = sneaky_insert_extra_moment (w); prepare (w); - iter->process (w); + if (iter->ok ()) + iter->process (w); one_time_step (); } diff --git a/lily/include/repeated-music.hh b/lily/include/repeated-music.hh index b7ebb339d8..5274e35b8f 100644 --- a/lily/include/repeated-music.hh +++ b/lily/include/repeated-music.hh @@ -58,6 +58,7 @@ public: Moment body_length_mom () const; Moment alternatives_length_mom (bool fold) const; + Moment alternatives_volta_length_mom () const; DECLARE_SCHEME_CALLBACK(unfolded_music_length, (SCM)); DECLARE_SCHEME_CALLBACK(volta_music_length, (SCM)); diff --git a/lily/include/unfolded-repeat-iterator.hh b/lily/include/unfolded-repeat-iterator.hh index 11b6a8fef3..272365ecd4 100644 --- a/lily/include/unfolded-repeat-iterator.hh +++ b/lily/include/unfolded-repeat-iterator.hh @@ -1,76 +1,3 @@ -/* - unfolded-repeat-iterator.hh -- declare Unfolded_repeat_iterator - - source file of the GNU LilyPond music typesetter - - (c) 1999--2000 Han-Wen Nienhuys - - */ -#ifndef UNFOLDED_REPEAT_ITERATOR_HH -#define UNFOLDED_REPEAT_ITERATOR_HH - -#include "music-iterator.hh" - -/** - Iterate repeats. First do body, then alternatives one by one, - optionally interspersed by the body. - */ -class Unfolded_repeat_iterator : public Music_iterator -{ - void add_repeat_command (SCM); - -public: - VIRTUAL_COPY_CONS (Music_iterator); - /** - How often have we done the body (assuming bodies are interspersed.)? - */ - int done_count_; - static SCM constructor_cxx_function; - - /* - are we now busy doing the body? - - */ - bool do_main_b_; - - /* - are we doing volta's? - */ - bool volta_b_; - - /** How far have we progressed into the repeat. - This excludes the elt currently being iterated. - */ - Moment here_mom_; - int alternative_count_i_; - Music_iterator * current_iter_p_; - - /// pointer to the alternative that will be processed next. - SCM alternative_cons_; - ~Unfolded_repeat_iterator(); - Unfolded_repeat_iterator (); - Unfolded_repeat_iterator (Unfolded_repeat_iterator const &); -protected: - virtual void construct_children (); - virtual Moment pending_moment () const; - virtual void process (Moment); - virtual Music_iterator *try_music_in_children (Music *) const; - virtual void skip (Moment); - virtual SCM get_music (Moment) const; - - virtual bool ok () const; - virtual void next_element (bool side_effect); -}; - -class Volta_repeat_iterator : public Unfolded_repeat_iterator -{ -public: - Volta_repeat_iterator (); - static SCM constructor_cxx_function; - VIRTUAL_COPY_CONS(Music_iterator); -}; - - -#endif /* UNFOLDED_REPEAT_ITERATOR_HH */ +#error diff --git a/lily/repeated-music.cc b/lily/repeated-music.cc index 9ff853a9a6..32e8202e81 100644 --- a/lily/repeated-music.cc +++ b/lily/repeated-music.cc @@ -89,6 +89,23 @@ Repeated_music::alternatives_length_mom (bool fold) const return m; } +/* + Sum all duration of all available alternatives. This is for the case + of volta repeats, where the alternatives are iterated just as they + were entered. */ +Moment +Repeated_music::alternatives_volta_length_mom () const +{ + SCM p = alternatives ()->music_list (); + Moment m; + while (gh_pair_p (p)) + { + m = m + unsmob_music (gh_car (p))->length_mom (); + p = gh_cdr (p); + } + return m; +} + Moment Repeated_music::body_length_mom () const { @@ -133,6 +150,6 @@ SCM Repeated_music::volta_music_length (SCM m) { Repeated_music* r = dynamic_cast (unsmob_music (m)); - Moment l = r->body_length_mom () + r->alternatives_length_mom (false); + Moment l = r->body_length_mom () + r->alternatives_volta_length_mom (); return l.smobbed_copy (); } diff --git a/lily/sequential-music-iterator.cc b/lily/sequential-music-iterator.cc index 281b97c167..ff0940e3d5 100644 --- a/lily/sequential-music-iterator.cc +++ b/lily/sequential-music-iterator.cc @@ -99,10 +99,18 @@ void Sequential_music_iterator::descend_to_child () { Translator_group * child_report = child_report = iter_p_->report_to_l (); + Translator_group * me_report = report_to_l (); + if (dynamic_cast (iter_p_)) child_report = child_report->daddy_trans_l_; - - if (report_to_l()->depth_i () < child_report->depth_i ()) + + Translator_group * c = child_report; + while (c && c != me_report) + { + c= c->daddy_trans_l_; + } + + if (c == me_report) set_translator (child_report); } diff --git a/lily/unfolded-repeat-iterator.cc b/lily/unfolded-repeat-iterator.cc index 89e5ba2fc6..8ad34fe331 100644 --- a/lily/unfolded-repeat-iterator.cc +++ b/lily/unfolded-repeat-iterator.cc @@ -7,13 +7,80 @@ */ - +/* + This is too hairy. Maybe split into subclasses for volta and full + unfold? + + */ +#include "music-iterator.hh" #include "repeated-music.hh" #include "music-list.hh" -#include "unfolded-repeat-iterator.hh" #include "debug.hh" #include "translator-group.hh" +/** + Iterate repeats. First do body, then alternatives one by one, + optionally interspersed by the body. + */ +class Unfolded_repeat_iterator : public Music_iterator +{ + void add_repeat_command (SCM); + +public: + VIRTUAL_COPY_CONS (Music_iterator); + /** + How often have we done the body (assuming bodies are interspersed.)? + + In volta: the number to print in the bracket. + */ + int done_count_; + static SCM constructor_cxx_function; + + /* + are we now busy doing the body? + + */ + bool do_main_b_; + + /* + are we doing volta's? + */ + bool volta_b_; + + /** How far have we progressed into the repeat. + This excludes the elt currently being iterated. + */ + Moment here_mom_; + int alternative_count_i_; + Music_iterator * current_iter_p_; + + /// pointer to the alternative that will be processed next. + SCM alternative_cons_; + ~Unfolded_repeat_iterator(); + Unfolded_repeat_iterator (); + Unfolded_repeat_iterator (Unfolded_repeat_iterator const &); +protected: + virtual void construct_children (); + virtual Moment pending_moment () const; + virtual void process (Moment); + virtual Music_iterator *try_music_in_children (Music *) const; + virtual void skip (Moment); + virtual SCM get_music (Moment) const; + + virtual bool ok () const; + virtual void next_element (bool side_effect); +}; + +class Volta_repeat_iterator : public Unfolded_repeat_iterator +{ +public: + Volta_repeat_iterator (); + static SCM constructor_cxx_function; + VIRTUAL_COPY_CONS(Music_iterator); +}; + + + Unfolded_repeat_iterator::~Unfolded_repeat_iterator () { delete current_iter_p_; @@ -83,7 +150,20 @@ Unfolded_repeat_iterator::next_element (bool side_effect) if (volta_b_) { - String repstr = to_str (done_count_ + 1); + String repstr = to_str (done_count_ + 1) + "."; + + /* + we're coming in from main, so we're always on the first repeat. + */ + assert (done_count_ == 0); + + if (done_count_ == 0 + && alternative_count_i_ < repmus->repeat_count ()) + { + done_count_ += repmus->repeat_count () - alternative_count_i_; + repstr = "1.--" + to_str (done_count_ + 1) + "."; + } + if (do_repcommands) add_repeat_command (gh_list (ly_symbol2scm ("volta"), ly_str02scm (repstr.ch_C()), SCM_UNDEFINED)); @@ -142,7 +222,7 @@ Unfolded_repeat_iterator::next_element (bool side_effect) { if (do_repcommands) { - String repstr = to_str (done_count_ + 1); + String repstr = to_str (done_count_ + 1) + "."; add_repeat_command (gh_list (ly_symbol2scm ("volta"), ly_str02scm (repstr.ch_C()), SCM_UNDEFINED)); add_repeat_command (ly_symbol2scm ("end-repeat")); @@ -164,7 +244,7 @@ Unfolded_repeat_iterator::next_element (bool side_effect) bool Unfolded_repeat_iterator::ok () const { - return current_iter_p_ ; + return current_iter_p_; } Moment @@ -195,6 +275,11 @@ Unfolded_repeat_iterator::construct_children () current_iter_p_ = get_iterator_p (unsmob_music (gh_car (alternative_cons_))); do_main_b_ = false; } + + while (current_iter_p_ && !current_iter_p_-> ok()) + { + next_element(true); + } } /*