From: Bertrand Bordage Date: Thu, 1 Sep 2011 21:18:52 +0000 (+0200) Subject: New partcombineUp and partcombineDown functions X-Git-Tag: release/2.15.14-1~16 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=bb7cac7b276bd7d1335523f3be8df815cf894ece;p=lilypond.git New partcombineUp and partcombineDown functions Fix issue 1321 --- diff --git a/input/regression/part-combine-3voices.ly b/input/regression/part-combine-3voices.ly new file mode 100644 index 0000000000..169b522276 --- /dev/null +++ b/input/regression/part-combine-3voices.ly @@ -0,0 +1,18 @@ +\version "2.15.14" + +\header { + texidoc ="It is possible to use the part combiner for three + voices with \\partcombineUp and \\partcombineDown." +} + + +soprano = { d''2 f'' g'' } +alto = { a' c''4 d'' e''2 } +tenor = { f'2 a'4 b' c''2 } +basso = { d'4 e' f' g' g'2 } + +\new Staff << \partcombineUp \soprano \alto \\ \basso >> + +\new Staff << \soprano \\ \partcombineDown \tenor \basso >> + + diff --git a/lily/part-combine-iterator.cc b/lily/part-combine-iterator.cc index 4583d221f6..9ab0495ae1 100644 --- a/lily/part-combine-iterator.cc +++ b/lily/part-combine-iterator.cc @@ -65,6 +65,11 @@ private: Moment start_moment_; SCM split_list_; + SCM direction_; + SCM directionOne_; + SCM directionTwo_; + SCM horizontalShiftOne_; + SCM horizontalShiftTwo_; Stream_event *unisono_event_; Stream_event *solo_one_event_; @@ -133,6 +138,11 @@ Part_combine_iterator::Part_combine_iterator () first_iter_ = 0; second_iter_ = 0; split_list_ = SCM_EOL; + direction_ = SCM_BOOL_F; + directionOne_ = scm_from_int (1); + directionTwo_ = scm_from_int (-1); + horizontalShiftOne_ = scm_from_int (0); + horizontalShiftTwo_ = scm_from_int (1); state_ = APART; playing_state_ = APART; last_playing_ = APART; @@ -349,6 +359,17 @@ Part_combine_iterator::construct_children () { start_moment_ = get_outlet ()->now_mom (); split_list_ = get_music ()->get_property ("split-list"); + direction_ = get_music ()->get_property ("direction"); + if (is_direction (direction_)) + { + directionOne_ = direction_; + directionTwo_ = direction_; + if (scm_is_true (scm_negative_p (direction_))) + { + horizontalShiftOne_ = scm_from_int (1); + horizontalShiftTwo_ = scm_from_int (0); + } + } Context *c = get_outlet (); @@ -369,6 +390,8 @@ Part_combine_iterator::construct_children () Context *two = handles_[CONTEXT_TWO].get_context (); set_context (two); second_iter_ = unsmob_iterator (get_iterator (unsmob_music (scm_cadr (lst)))); + Context *shared = handles_[CONTEXT_SHARED].get_context (); + set_context (shared); /* Mimic all settings of voiceOne/voiceTwo for the two separate voices...*/ /* FIXME: Is there any way to use the definition of \voiceOne/\voiceTwo @@ -391,16 +414,20 @@ Part_combine_iterator::construct_children () { SCM sym = ly_symbol2scm (*p); execute_pushpop_property (one, sym, - ly_symbol2scm ("direction"), scm_from_int (1)); + ly_symbol2scm ("direction"), directionOne_); execute_pushpop_property (two, sym, - ly_symbol2scm ("direction"), scm_from_int (-1)); + ly_symbol2scm ("direction"), directionTwo_); + + if (scm_is_number (direction_)) + execute_pushpop_property (shared, sym, + ly_symbol2scm ("direction"), direction_); } /* Handle horizontal shifts for crossing notes */ execute_pushpop_property (one, ly_symbol2scm ("NoteColumn"), - ly_symbol2scm ("horizontal-shift"), scm_from_int (0)); + ly_symbol2scm ("horizontal-shift"), horizontalShiftOne_); execute_pushpop_property (two, ly_symbol2scm ("NoteColumn"), - ly_symbol2scm ("horizontal-shift"), scm_from_int (1)); + ly_symbol2scm ("horizontal-shift"), horizontalShiftTwo_); /* Also handle MultiMeasureRest positions for voice 1/2 */ execute_pushpop_property (one, ly_symbol2scm ("MultiMeasureRest"), ly_symbol2scm ("staff-position"), scm_from_int (4)); diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index c8054927b0..af09d9db14 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -776,7 +776,21 @@ partcombine = (_i "Take the music in @var{part1} and @var{part2} and typeset so that they share a staff.") (make-part-combine-music parser - (list part1 part2))) + (list part1 part2) #f)) + +partcombineUp = +#(define-music-function (parser location part1 part2) (ly:music? ly:music?) + (_i "Take the music in @var{part1} and @var{part2} and typeset so +that they share a staff with stems directed upward.") + (make-part-combine-music parser + (list part1 part2) UP)) + +partcombineDown = +#(define-music-function (parser location part1 part2) (ly:music? ly:music?) + (_i "Take the music in @var{part1} and @var{part2} and typeset so +that they share a staff with stems directed downward.") + (make-part-combine-music parser + (list part1 part2) DOWN)) partcombineForce = #(define-music-function (location parser type once) (symbol-or-boolean? boolean?) diff --git a/scm/part-combiner.scm b/scm/part-combiner.scm index c492701c91..61fbf95f50 100644 --- a/scm/part-combiner.scm +++ b/scm/part-combiner.scm @@ -243,7 +243,7 @@ LilyPond version 2.8 and earlier." (ly:interpret-music-expression (make-non-relative-music music) global) context-list)) -(define-public (make-part-combine-music parser music-list) +(define-public (make-part-combine-music parser music-list direction) (let* ((m (make-music 'PartCombineMusic)) (m1 (make-non-relative-music (context-spec-music (first music-list) 'Voice "one"))) (m2 (make-non-relative-music (context-spec-music (second music-list) 'Voice "two"))) @@ -252,6 +252,7 @@ LilyPond version 2.8 and earlier." (evs1 (recording-group-emulate m1 listener))) (set! (ly:music-property m 'elements) (list m1 m2)) + (set! (ly:music-property m 'direction) direction) (set! (ly:music-property m 'split-list) (if (and (assoc "one" evs1) (assoc "two" evs2)) (determine-split-list (reverse! (assoc-get "one" evs1) '())