From: Dan Eble Date: Sat, 18 Apr 2015 03:01:55 +0000 (-0400) Subject: Issue 4348: Part combiner: move direction handling out of iterator X-Git-Tag: release/2.19.19-1~5 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3740ac23c9e222602cec4ddc6c38b58504f17673;p=lilypond.git Issue 4348: Part combiner: move direction handling out of iterator --- diff --git a/input/regression/display-lily-tests.ly b/input/regression/display-lily-tests.ly index cbbebd6539..6ff266c4ef 100644 --- a/input/regression/display-lily-tests.ly +++ b/input/regression/display-lily-tests.ly @@ -237,7 +237,11 @@ stderr of this run." %% \partcombine \test ##[ \partcombine { c4 e4 } -{ d4 f4 } #] % PartCombineMusic UnrelativableMusic +{ d4 f4 } #] +\test ##[ \partcombineUp { c2 e2 } +{ d2 f2 } #] +\test ##[ \partcombineDown { c1 e1 } +{ d1 f1 } #] %% Cue notes \test ##[ \cueDuring #"foo" #1 { c4 d4 } #] diff --git a/lily/part-combine-iterator.cc b/lily/part-combine-iterator.cc index d1a8f019f3..4d1baec756 100644 --- a/lily/part-combine-iterator.cc +++ b/lily/part-combine-iterator.cc @@ -65,11 +65,6 @@ 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_; @@ -146,11 +141,6 @@ 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; chosen_part_ = 1; playing_state_ = PLAYING_OTHER; @@ -369,17 +359,6 @@ 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 (); @@ -402,44 +381,6 @@ Part_combine_iterator::construct_children () second_iter_ = Music_iterator::unsmob (get_iterator (Music::unsmob (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 - directly??? */ - char const *syms[] - = - { - "Stem", - "DynamicLineSpanner", - "Tie", - "Dots", - "MultiMeasureRest", - "Rest", - "Slur", - "TextScript", - "Script", - 0 - }; - - for (char const **p = syms; *p; p++) - { - SCM sym = ly_symbol2scm (*p); - execute_pushpop_property (one, sym, - ly_symbol2scm ("direction"), directionOne_); - - execute_pushpop_property (two, sym, - 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"), horizontalShiftOne_); - execute_pushpop_property (two, ly_symbol2scm ("NoteColumn"), - ly_symbol2scm ("horizontal-shift"), horizontalShiftTwo_); - } IMPLEMENT_LISTENER (Part_combine_iterator, set_busy); diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 9b1d36623b..cbba26a652 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -1131,24 +1131,36 @@ a music expression containing simultaneous voices, where @var{part1} and @var{part2} are combined into one voice where appropriate. Optional @var{chord-range} sets the distance in steps between notes that may be combined into a chord or unison.") - (make-part-combine-music parser - (list part1 part2) #f chord-range)) + #{ \context Staff << + \context Voice = "one" \with { \voiceOne } {} + \context Voice = "two" \with { \voiceTwo } {} + \context Voice = "shared" {} + #(make-part-combine-music parser (list part1 part2) #f chord-range) + >> #} ) partcombineUp = #(define-music-function (parser location chord-range part1 part2) ((number-pair? '(0 . 8)) 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 chord-range)) + #{ \context Staff << + \context Voice = "one" \with { \voiceOne } {} + \context Voice = "two" \with { \voiceThree } {} + \context Voice = "shared" \with { \voiceOne } {} + #(make-part-combine-music parser (list part1 part2) UP chord-range) + >> #} ) partcombineDown = #(define-music-function (parser location chord-range part1 part2) ((number-pair? '(0 . 8)) 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 chord-range)) + #{ \context Staff << + \context Voice = "one" \with { \voiceFour } {} + \context Voice = "two" \with { \voiceTwo } {} + \context Voice = "shared" \with { \voiceTwo } {} + #(make-part-combine-music parser (list part1 part2) DOWN chord-range) + >> #} ) partcombineForce = #(define-music-function (location parser type once) (boolean-or-symbol? boolean?) diff --git a/scm/define-music-display-methods.scm b/scm/define-music-display-methods.scm index ca532c5029..cca78ffec2 100644 --- a/scm/define-music-display-methods.scm +++ b/scm/define-music-display-methods.scm @@ -1012,6 +1012,7 @@ Otherwise, return #f." (define-extra-display-method PartCombineMusic (expr parser) (with-music-match (expr (music 'PartCombineMusic + direction ?dir elements ((music 'UnrelativableMusic element (music 'ContextSpeccedMusic context-id "one" @@ -1022,11 +1023,35 @@ Otherwise, return #f." context-id "two" context-type 'Voice element ?sequence2))))) - (format #f "\\partcombine ~a~a~a" + (format #f "\\partcombine~a ~a~a~a" + (cond ((equal? ?dir UP) "Up") + ((equal? ?dir DOWN) "Down") + (else "")) (music->lily-string ?sequence1 parser) (new-line->lily-string) (music->lily-string ?sequence2 parser)))) +(define-extra-display-method ContextSpeccedMusic (expr parser) + "If `expr' is a \\partcombine expression, return \"\\partcombine ...\". +Otherwise, return #f." + (with-music-match + (expr (music 'ContextSpeccedMusic + context-type 'Staff + element (music 'SimultaneousMusic + elements ((music 'ContextSpeccedMusic + context-id "one" + context-type 'Voice) + (music 'ContextSpeccedMusic + context-id "two" + context-type 'Voice) + (music 'ContextSpeccedMusic + context-id "shared" + context-type 'Voice) + ?pc-music)))) + (with-music-match + (?pc-music (music 'PartCombineMusic)) + (format #f "~a" (music->lily-string ?pc-music parser))))) + (define-display-method UnrelativableMusic (expr parser) (music->lily-string (ly:music-property expr 'element) parser))