On 15 September 2010 03:40, Carl Sorensen <c_soren...@byu.edu> wrote:
> Note that at this point, I haven't changed the value to which I am setting > 'measurePosition. So, can anybody help me see why this code doesn't work? It looks like adding the extra iteration step (ApplyContext) delays the 'measurePosition setting. It might be the case that it ends up being overridden by the Timing_translator before it's been read by the autobeamer. Using an iterator directly seems to work (see attached), but might be considered a dubious hack; what do you think? :) Cheers, Neil
From fe26d8b7ddce8fb00a072853d938e6a612a20979 Mon Sep 17 00:00:00 2001 From: Neil Puttock <n.putt...@gmail.com> Date: Thu, 16 Sep 2010 23:54:10 +0100 Subject: [PATCH] Possible fix for #372. --- lily/partial-iterator.cc | 27 +++++++++++++++++++++++++++ scm/define-music-types.scm | 6 ++++++ scm/ly-syntax-constructors.scm | 6 ++++-- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 lily/partial-iterator.cc diff --git a/lily/partial-iterator.cc b/lily/partial-iterator.cc new file mode 100644 index 0000000..bb175d4 --- /dev/null +++ b/lily/partial-iterator.cc @@ -0,0 +1,27 @@ +#include "context.hh" +#include "moment.hh" +#include "music.hh" +#include "simple-music-iterator.hh" + +class Partial_iterator : public Simple_music_iterator +{ +public: + DECLARE_SCHEME_CALLBACK (constructor, ()); + protected: + virtual void process (Moment); +}; + +void +Partial_iterator::process (Moment m) +{ + Moment length + = robust_scm2moment (get_music ()->get_property ("partial-length"), + Moment (0)); + Context *ctx = get_outlet (); + Moment now = ctx->now_mom (); + ctx->set_property ("measurePosition", (now - length).smobbed_copy ()); + + Simple_music_iterator::process (m); +} + +IMPLEMENT_CTOR_CALLBACK (Partial_iterator); diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index 7f4525e..96fe7c2 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -349,6 +349,12 @@ Syntax: @code{\\override} [ @var{context} @code{.} ] (types . (general-music break-event page-turn-event event)) )) + (PartialSet + . ((description . "Create an anacrusis.") + (iterator-ctor . ,ly:partial-iterator::constructor) + (types . (general-music partial-set)) + )) + (PartCombineMusic . ((description . "Combine two parts on a staff, either merged or as separate voices.") diff --git a/scm/ly-syntax-constructors.scm b/scm/ly-syntax-constructors.scm index decc515..d73f6b9 100644 --- a/scm/ly-syntax-constructors.scm +++ b/scm/ly-syntax-constructors.scm @@ -250,10 +250,12 @@ into a @code{MultiMeasureTextEvent}." (define-ly-syntax-simple (partial dur) "Make a partial measure." - (let ((mom (ly:moment-sub ZERO-MOMENT (ly:duration-length dur)))) + (let ((mom (ly:duration-length dur))) ;; We use `descend-to-context' here instead of `context-spec-music' to ;; ensure \partial still works if the Timing_translator is moved (descend-to-context - (context-spec-music (make-property-set 'measurePosition mom) 'Timing) + (context-spec-music (make-music 'PartialSet + 'partial-length mom) + 'Timing) 'Score))) -- 1.7.0.4
_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel